Hi all, I am new to VBA so sorry if this is obvious.
I have a macro which copies sheets from a Masterfile into a Template output file containing formatting.
Because the output can have varying column numbers I have written a command which clears formatting from whenever the data finishes.
The second demand then clears contents of column A (which contains lookup references, hence isn't wanted for the output).
These commands work as when I run the macro the first sheet is formatted correctly.
However, it doesn't loop the formatting commands through to the other worksheets.
My code reads as below.
' Clear formatting for all columns after last column
' Clear contents of Column A
Dim ws As Worksheet
For Each ws In Worksheets
Set LastCell = Cells.Find(What:="*", After:=Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)
LastColumn = LastCell.Column
Range(Columns(LastColumn + 1), Columns(Columns.Count)).ClearFormats
Columns(1).ClearContents
Next
Any help at all would be appreciated!
Bookmarks