shell路径变量 vba,如何在路径内使用变量编写VBA

这篇博客介绍了在VBA中如何将单元格值作为路径字符串的一部分,以指定保存工作簿的位置。通过修正代码顺序和使用字符串连接操作,确保了变量在路径中的正确插入。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This is my second post on this site and an I am relatively new to VBA.

My today question is,

How can I add a cell value to the Path String to designate the folder where I would like the workbook to be saved.

Dim Path As String

Dim FileName1 As String

Dim FileName2 As String

Path = "D:\folder1\folder2\Projects\The FILES\theFILES\"FileName1"\

FileName1 = Range("B6")

FileName2 = Range("A1")

ActiveWorkbook.SaveAs Filename:=Path & FileName2 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled

Thanks in advance!

解决方案

Answer to stated question

Path = "D:\folder1\folder2\Projects\The FILES\theFILES\" & FileName1 & "\"

Also see additional feedback and corrected code for other feedback.

Long E

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值