Bypass Part of Code After Initial Run

JLouis

Active Member
Joined
Jan 1, 2004
Messages
295
Office Version
  1. 365
Platform
  1. Windows
I have a macro that I run several times over and over. It's an import of data macro. Part of this code is a unhide/hide rows to hide the rows not being used. The unhide code runs at the begining, the hide runs at the end after the data has been imported. Because it deals with multiple sheets it takes a long time to run and I don't need to run the unhide/hide part after it has run the first time.

The macro runs from a custom toolbar button, so 2 macros are not a viable solution. I'm thinking maybe checking if any rows are hidden and if true bypass that part., but I'm not sure what the syntax would be or the structure to apply to the begining and the end of the code.

Any suggestions would be appreciated.

VBA Code:
Application.DisplayAlerts = False
UnhideAll
Application.EnableEvents = False
Dim path As String
path = ThisWorkbook.path
Application.ScreenUpdating = False

Do Some Stuff

VBA Code:
Application.EnableEvents = True
HideAll
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I was able to figue this out. It was embarassing simple. Checking a known row to be hidden or unhidden and skip to a label. Repeated the process at the end.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,497
Messages
6,125,157
Members
449,208
Latest member
emmac

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