Excel Locks up when vba runs

erutherford

Active Member
Joined
Dec 19, 2016
Messages
449
This has happened before because I didn't "unload a userform during the execution of the code. When that doesn't appear to be the answer this time. Has to be something pretty simple, just not seeing it. It doesn't matter where I unload the forms, excel locks up at the printpreview. Thanks for reading!
VBA Code:
<
Sheets("Entries").Range("J:J").EntireColumn.Hidden = True
Sheets("Entries").Range("K:K").EntireColumn.Hidden = False
Sheets("Entries").Range("A2:I52", "K2:K52").PrintPreview
Sheets("Entries").Range("J:J").EntireColumn.Hidden = False
Sheets("Entries").Range("K:K").EntireColumn.Hidden = True
Sheets("Entries").Range("L:L").EntireColumn.Hidden = True
'Unload UserForm11
'Unload UserForm12
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The code you attached doesn't cause any issue so you need to look elsewhere. See if you can attach a dummy file (same layout and macros as original) without sensible data.
 
Upvote 0
I'll try to rephrase my answer: your code works perfectly WITH the Print Preview line in my dummy file, that's why I said to look elsewhere in your project for the cause of your issue.
 
Upvote 0
Needed to unload the form first, then all works well. I thought I tried this but obviously didn't have it in the right spot. Thanks "rollis13" for the nudge.
VBA Code:
Private Sub CommandButton3_Click() 'Prints Packet Chklst
Unload UserForm12
Sheets("Entries").Range("J:J").EntireColumn.Hidden = True
Sheets("Entries").Range("L:L").EntireColumn.Hidden = False
Sheets("Entries").Range("A2:J52", "L2:L52").PrintPreview
Sheets("Entries").Range("J:J").EntireColumn.Hidden = False
Sheets("Entries").Range("L:L").EntireColumn.Hidden = True
UserForm12.Show
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top