重写我的问题:
Sub Path()
Dim path As Range
Dim shPivot As Worksheet
Set shPivot = ActiveWorkbook.Sheets("Pivot")
Set path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & path & "\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")
路径是单元格中的日期。当此单元格更改时,我希望目录根据路径更改。
答案 0 :(得分:3)
两件事
这是你在尝试的吗?
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
format(path,"DD-MM-YYYY") & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")
<强>后续强>
在这种情况下使用此
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
path & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")
如果有任何不需要的空格,则必须使用TRIM
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
Trim(path) & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")