Reputation: 708
I'm working on creating a monthly consolidation function which doesn't like how I'm using this particular snippet of my code:
For Each ws In Worksheets
If Len(ws.Name) <= 5 Then
ws.Range("B7:C7").Select
Selection.ClearContents
Selection.AutoFill Destination:=Range("B7:C100"), Type:=xlFillDefault
Range("B7:C100").Select
End If
Next
All client profiles are filled out via a template which self duplicates for each new individual so the profiles are all standardised. All user profiles are <=5 characters (acronyms). So the intent of my code is to check if the tab is <=5 characters, and then if it is - select the first range B7:C7 and clear this. Next we apply this cleared filter to all the other cells as well (down to 100).
I've defined ws as my Worksheet variable and I don't understand why I can't set the ws.range as B7:C7. I'd appreciate your insight!
I've attached a snapshot of what the form looks like.
Upvotes: 3
Views: 207
Reputation: 10715
For Each ws In Worksheets
If Len(ws.Name) <= 5 Then ws.Range("B7:C100").ClearContents
Next
Notes:
the .AutoFill is not bad but here is not needed
Upvotes: 5