jbesclapez
Active Member
- Joined
- Feb 6, 2010
- Messages
- 275
Hi THere,
I need a macro to run on all sheets and do an autofill if C2 and C3 are not empty...
This has to run on all the worksheets named below...
However it seems it does the first one and not the otehrs.
No idea why
Thanks for having a look!
I need a macro to run on all sheets and do an autofill if C2 and C3 are not empty...
This has to run on all the worksheets named below...
However it seems it does the first one and not the otehrs.
No idea why
Thanks for having a look!
VBA Code:
Dim rs As Worksheet
Dim LastRow As Long
'All worksheet excep OneToOne as the structure of OneToOne is different
For Each rs In ThisWorkbook.Worksheets
If rs.Name = "A_R" Or rs.Name = "A_C" Or rs.Name = "A_L" Or rs.Name = "A_" Then
rs.Select
rs.Range("J3:N10001").ClearContents
LastRow = rs.Cells(1, 1).End(xlDown).Row
rs.Range("J2:N2").Select
If IsEmpty(rs.Range("C2").Value) = False And IsEmpty(rs.Range("C3").Value = False) Then
Selection.AutoFill Destination:=rs.Range("J2:N" & LastRow), Type:=xlFillDefault
End If
End If
Next rs