Hi all, I'm trying to repeat a process for different files and didn't want to repeat the codes. Therefore I'm trying to build sthg like this:
SheetName = Array("math", "english"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
For i = 0 To UBound(SheetName)
Select Case SheetName(i)
Case Is = "math"
Call Cut_n_Paste(SheetName(i))
Case Is = "english"
Call Cut_n_Paste(SheetName(i))
End Select
Next
End Sub
------------------------
Sub Cut_n_Paste(SheetName)
Sheets(SheetName).Select
Columns("A:J"
.Select
Selection.ClearContents
Range("A1"
.Select
Workbooks.Open FileName:= _
"\\WINFSP\de$\school\subjects\(SheetName) & ".mtm""
However, I find that I can't get pass the last line of codes. What can I do to open the file name as according to the sheet name in case 1, 2 etc. Eg of a file name is math.mtm, english.mtm. The error I got is that the data type is different. How should I define the data type?
Thanks a lot for your help
SheetName = Array("math", "english"
For i = 0 To UBound(SheetName)
Select Case SheetName(i)
Case Is = "math"
Call Cut_n_Paste(SheetName(i))
Case Is = "english"
Call Cut_n_Paste(SheetName(i))
End Select
Next
End Sub
------------------------
Sub Cut_n_Paste(SheetName)
Sheets(SheetName).Select
Columns("A:J"
Selection.ClearContents
Range("A1"
Workbooks.Open FileName:= _
"\\WINFSP\de$\school\subjects\(SheetName) & ".mtm""
However, I find that I can't get pass the last line of codes. What can I do to open the file name as according to the sheet name in case 1, 2 etc. Eg of a file name is math.mtm, english.mtm. The error I got is that the data type is different. How should I define the data type?
Thanks a lot for your help