back soft

مطالب مرتبط با «vba copy worksheet name» در back soft | نویسنده: استخدام کار

VBA: Copy Worksheet only working when when file already exists

Vote count: 0 I want to copy a sheet from files X,Y and Z to a new file Master11Aug2016. If there already exists a file called Master11Aug2016 in the folder it works, but when there is not it retus an error on the copy line stating . Dim place As String place = "C:Users..." Dim fname As String dt = Format(CStr(Now), "ddmmmyy") fname = "Master" & dt Dim path As String path = place & fname & ".xlsx" Workbooks.Add ActiveWorkbook.SaveAs Filename:=(path) Dim X, Y, Z As String X = Dir(place & "X.xlsx") Y = Dir(place & "Y.xlsx") Z = Dir(place & "Z.xlsx") Workbooks.Open (X) Workbooks(X).Sheets("Sheet1").Calculate Workbooks(X).Sheets("Sheet1").Copy Before:=Workbooks(path).Sheets(1) [error here] Workb...

ادامه مطلب