Pestomania
Active Member
- Joined
- May 30, 2018
- Messages
- 292
- Office Version
- 365
- Platform
- Windows
Hi. So I am using a userform to determine the color of a sheet. But it keeps having issues getting past one sheet. I'll show the code below.
At this point a user form pops up with four buttons "SMALL, MEDIUM, LARGE, NONE"
When the user selects a button it will color a specific range of cells.
An example:
It works for one sheet but when it goes to the second it says that the "RunTime Error 1004" "Application-Defined or object defined erroe" and it highlights .Color = RGB.
I don't know why it works once but not twice or third.
Code:
Sub ColorAllSheets ()
Dim wsd as worksheet
Application.DisplayAlerts = False
For each wsd in worksheets If left(wsd.name,4) = "asse" or left(wsd.name,4)="ASSE" then
Wsd.select
Eun "Userform_Initialize"
End if
Next WSD
End sub
When the user selects a button it will color a specific range of cells.
An example:
Code:
Sub ColorYellow()
Range("T13:U21").Select
With Selection.Interior
.Color = RGB(255,255,0)
.TintAndShade = 0
End With
End Sub
It works for one sheet but when it goes to the second it says that the "RunTime Error 1004" "Application-Defined or object defined erroe" and it highlights .Color = RGB.
I don't know why it works once but not twice or third.
Last edited: