Hello All,
Please help~I got stuck on this problem for a couple days already. I appreciate your insightful input.
On excel, I created a macro under Tools-->Macros-->Record New Macro.. to record a chain of actions from turning on auto filter to print preview. If I choose to run this macro manually under Tools --> Macros -- Macros..-->Run, everything will work properly.
I created an User Form with a button that suppose to triger the macro I recorded. However, every time I click on the button on that End User Form, my screen would be froze and my VBA screen will say (running) on top of it. I have to use "Ctrl+Alt+Delete" to kill it. I checked on all the codes for that Macro (which was stored in a module), it doesn't look like I got any infinate loop. So, I am wondering if there is anything has to do with the codes under the Button (Module5.A1PrintPreviewFlagY)?
So here is the codes of my Macro which is stored in a module. (It's stored in Module5 by default when I recorded using excel's -->Tools-->Record Macro)
----------------------------------------------------------
Sub A1PrintPreviewFlagY()
Rows("1:1").Select
Selection.AutoFilter
Columns("A:BM").Select
Selection.EntireColumn.Hidden = False
Columns("G:I").Select
Selection.EntireColumn.Hidden = True
Columns("M:N").Select
Selection.EntireColumn.Hidden = True
Columns("P
").Select
Selection.EntireColumn.Hidden = True
Columns("R:R").Select
Selection.EntireColumn.Hidden = True
Columns("U:V").Select
Selection.EntireColumn.Hidden = True
Columns("X:X").Select
Selection.EntireColumn.Hidden = True
Columns("AC:AL").Select
Selection.EntireColumn.Hidden = True
Columns("AN:BC").Select
Selection.EntireColumn.Hidden = True
Columns("BE:BG").Select
Selection.EntireColumn.Hidden = True
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="Y"
Columns("A:BI").Select
Range("BI1").Activate
ActiveSheet.PageSetup.PrintArea = "$A:$BI"
ActiveWindow.SelectedSheets.PrintPreview
End Sub
--------------------------------------------------------
And here is the code for the button I tried to triger the macro:
Private Sub PrnCo1_Click()
Module5.A1PrintPreviewFlagY
End Sub
--------------------------------------------------------
Thank you very much and please please help!
Zabrina from the SF BayARea
Just another humble analyst & VBA newbie~
Please help~I got stuck on this problem for a couple days already. I appreciate your insightful input.
On excel, I created a macro under Tools-->Macros-->Record New Macro.. to record a chain of actions from turning on auto filter to print preview. If I choose to run this macro manually under Tools --> Macros -- Macros..-->Run, everything will work properly.
I created an User Form with a button that suppose to triger the macro I recorded. However, every time I click on the button on that End User Form, my screen would be froze and my VBA screen will say (running) on top of it. I have to use "Ctrl+Alt+Delete" to kill it. I checked on all the codes for that Macro (which was stored in a module), it doesn't look like I got any infinate loop. So, I am wondering if there is anything has to do with the codes under the Button (Module5.A1PrintPreviewFlagY)?
So here is the codes of my Macro which is stored in a module. (It's stored in Module5 by default when I recorded using excel's -->Tools-->Record Macro)
----------------------------------------------------------
Sub A1PrintPreviewFlagY()
Rows("1:1").Select
Selection.AutoFilter
Columns("A:BM").Select
Selection.EntireColumn.Hidden = False
Columns("G:I").Select
Selection.EntireColumn.Hidden = True
Columns("M:N").Select
Selection.EntireColumn.Hidden = True
Columns("P
Selection.EntireColumn.Hidden = True
Columns("R:R").Select
Selection.EntireColumn.Hidden = True
Columns("U:V").Select
Selection.EntireColumn.Hidden = True
Columns("X:X").Select
Selection.EntireColumn.Hidden = True
Columns("AC:AL").Select
Selection.EntireColumn.Hidden = True
Columns("AN:BC").Select
Selection.EntireColumn.Hidden = True
Columns("BE:BG").Select
Selection.EntireColumn.Hidden = True
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="Y"
Columns("A:BI").Select
Range("BI1").Activate
ActiveSheet.PageSetup.PrintArea = "$A:$BI"
ActiveWindow.SelectedSheets.PrintPreview
End Sub
--------------------------------------------------------
And here is the code for the button I tried to triger the macro:
Private Sub PrnCo1_Click()
Module5.A1PrintPreviewFlagY
End Sub
--------------------------------------------------------
Thank you very much and please please help!
Zabrina from the SF BayARea
Just another humble analyst & VBA newbie~