Hi,
I want to either merge these macros or create a macro to call on them but i keep running into the "Run-time error'1004'. These macros add drop down lists to specific cells in each sheet. I have tried combining them but running them separately is the only way I have managed to get them to run through each sheet. What am I missing!?
Thank you!
MACRO 1
MACRO 2
MACRO 3
MACRO 4
I want to either merge these macros or create a macro to call on them but i keep running into the "Run-time error'1004'. These macros add drop down lists to specific cells in each sheet. I have tried combining them but running them separately is the only way I have managed to get them to run through each sheet. What am I missing!?
Thank you!
MACRO 1
Code:
Sub DataValErrorsWG()
Dim Lastrow As Long
For Each Ws In Worksheets
Ws.Activate
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AG2:AG" & Lastrow).Validation.Delete
Application.ScreenUpdating = False
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AG2:AG" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="ERROR 1, ERROR 2, ERROR 3"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Application.ActiveWindow.FreezePanes = True
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
'Range("A1").Select
' ActiveSheet.Range("$A:$Cj").AutoFilter Field:=1, Criteria1:=RGB(255, _
'230, 153), Operator:=xlFilterCellColor
ActiveWindow.ScrollRow = 1
End If
Next Ws
End Sub
MACRO 2
Code:
Sub DataValYesNoWG()
Dim Lastrow As Long
For Each Ws In Worksheets
Ws.Activate
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AD2:AD" & Lastrow).Validation.Delete
Application.ScreenUpdating = False
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AD2:AD" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="NO,YES"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("W2:W" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="NO,YES"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("J2:M" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="NO,YES"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Application.ActiveWindow.FreezePanes = True
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
'Range("A1").Select
' ActiveSheet.Range("$A:$Cj").AutoFilter Field:=1, Criteria1:=RGB(255, _
'230, 153), Operator:=xlFilterCellColor
ActiveWindow.ScrollRow = 1
End If
Next Ws
End Sub
MACRO 3
Code:
Sub DataValPROGRAMWG()
Dim Lastrow As Long
For Each Ws In Worksheets
Ws.Activate
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("V2:V" & Lastrow).Validation.Delete
Application.ScreenUpdating = False
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("V2:V" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="PROGRAM 1,PROGRAM 2"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Application.ActiveWindow.FreezePanes = True
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
'Range("A1").Select
' ActiveSheet.Range("$A:$Cj").AutoFilter Field:=1, Criteria1:=RGB(255, _
'230, 153), Operator:=xlFilterCellColor
ActiveWindow.ScrollRow = 1
End If
Next Ws
End Sub
MACRO 4
Code:
Sub DataValSSSourceWG()
Dim Lastrow As Long
For Each Ws In Worksheets
Ws.Activate
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AJ2:AJ" & Lastrow).Validation.Delete
Application.ScreenUpdating = False
Lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("AJ2:AJ" & Lastrow).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:=SS1,SS2,SS3"
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True
Application.ActiveWindow.FreezePanes = True
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
'Range("A1").Select
' ActiveSheet.Range("$A:$Cj").AutoFilter Field:=1, Criteria1:=RGB(255, _
'230, 153), Operator:=xlFilterCellColor
ActiveWindow.ScrollRow = 1
End If
Next Ws
End Sub
Last edited: