Hi all!
I want to automatically check a number of files whether their column numbers corresponds to the number of columns of another sheet.
I have tried to solve that like this:
The main problem is that it only identifies the correct number of columns when the sheet of interest (which is called "korr") was the last sheet to be activated; if it is another one, it simply counts the columns of the first sheet. Therefore it seems that I am not properly formulating the Lastcol variable because activesheet is not referring to the sheet name that I am looking for.
I would be very grateful if someone could give me a hint of what I'm doing wrong! Couldn't find an alternative way of establishing column numbers so far...
Best regards,
Andreas
I want to automatically check a number of files whether their column numbers corresponds to the number of columns of another sheet.
I have tried to solve that like this:
VBA Code:
Workbooks.Open Filename:=Path2 & NewList(o), ReadOnly:=True, UpdateLinks:=False
For Each Sheet In ActiveWorkbook.Sheets
If Sheet.Name = "korr" Then
Lastcol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Else
End If
Next Sheet
Workbooks(Filename).Close savechanges:=False
Filename = Dir()
I would be very grateful if someone could give me a hint of what I'm doing wrong! Couldn't find an alternative way of establishing column numbers so far...
Best regards,
Andreas