I'm a newbie to VBA codes. I know I'm going to run into a lot of errors in this macros button. I can run the macros with no problem without it assigned to check boxes or buttons, but once I paste the macros in the code for an active x button; I run into errors. Please help. My code is shown below.
What's highlight is:
Columns ("T:W").Select <---error '1004'
Private Sub CommandButton1_Click()
'
' step1 Macro
'
'
Columns("AI:AP").Select
Range("AI2").Activate
Selection.EntireColumn.Hidden = False
Range("AK158:AK307").Select
Selection.Copy
Range("AL158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("AJ:AP").Select
Selection.EntireColumn.Hidden = True
Sheets("Parts Tracking").Select
'
' step2 Macro
'
'
Columns("T:W").Select
Selection.EntireColumn.Hidden = False
Range("T5:T154").Select
Selection.Copy
Range("U5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim MyRange As Range
Set MyRange = Range("U:U,V:V,W:W")
MyRange.EntireColumn.Hidden = Not MyRange.EntireColumn.Hidden
Application.GoTo Sheets(1).Range("D1"), True
Sheets("Parts Tracking").Select
'
' Pvtupdate Macro
'
'
Range("E5").Select
ActiveWorkbook.RefreshAll
'
' step3 Macro
'
'
Sheets("Quote Comparison").Select
Columns("AI:AP").Select
Range("AI6").Activate
Selection.EntireColumn.Hidden = False
Range("AO158:AO307").Select
Selection.Copy
Range("D158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim QcRange As Range
Set QcRange = Range("AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,AO:AO,AP:AP,F:F,G:G,H:H,I:I,J:J,K:K,L:L,M:M,N:N,O:O,P:P,Q:Q,R:R,S:S,T:T,U:U,V:V,W:W")
QcRange.EntireColumn.Hidden = Not QcRange.EntireColumn.Hidden
Application.GoTo Sheets(2).Range("c1"), True
'
' step4 Macro
'
'
Range("AO158:AO307").Select
Selection.Copy
Range("AP158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AP2").Select
Application.CutCopyMode = False
End Sub
What's highlight is:
Columns ("T:W").Select <---error '1004'
Private Sub CommandButton1_Click()
'
' step1 Macro
'
'
Columns("AI:AP").Select
Range("AI2").Activate
Selection.EntireColumn.Hidden = False
Range("AK158:AK307").Select
Selection.Copy
Range("AL158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("AJ:AP").Select
Selection.EntireColumn.Hidden = True
Sheets("Parts Tracking").Select
'
' step2 Macro
'
'
Columns("T:W").Select
Selection.EntireColumn.Hidden = False
Range("T5:T154").Select
Selection.Copy
Range("U5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim MyRange As Range
Set MyRange = Range("U:U,V:V,W:W")
MyRange.EntireColumn.Hidden = Not MyRange.EntireColumn.Hidden
Application.GoTo Sheets(1).Range("D1"), True
Sheets("Parts Tracking").Select
'
' Pvtupdate Macro
'
'
Range("E5").Select
ActiveWorkbook.RefreshAll
'
' step3 Macro
'
'
Sheets("Quote Comparison").Select
Columns("AI:AP").Select
Range("AI6").Activate
Selection.EntireColumn.Hidden = False
Range("AO158:AO307").Select
Selection.Copy
Range("D158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim QcRange As Range
Set QcRange = Range("AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,AO:AO,AP:AP,F:F,G:G,H:H,I:I,J:J,K:K,L:L,M:M,N:N,O:O,P:P,Q:Q,R:R,S:S,T:T,U:U,V:V,W:W")
QcRange.EntireColumn.Hidden = Not QcRange.EntireColumn.Hidden
Application.GoTo Sheets(2).Range("c1"), True
'
' step4 Macro
'
'
Range("AO158:AO307").Select
Selection.Copy
Range("AP158").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AP2").Select
Application.CutCopyMode = False
End Sub