How do I auto refresh my macro?

jjt1973

New Member
Joined
Jun 8, 2011
Messages
32
I have created a template that will be used by our national sales team. I have written a macro and will be adding more. This template will need to be able to refresh everytime it is opened so that the macros automatically turn on and refresh with each scenario. Here is the current macro running:

Sub channel()
'This macro will be used to hide row 3 if not active row.

If [E2].Value = "" Then
Range("A3:I3").EntireRow.Hidden = True
End If

If [E2].Value = MN Then
Range("A3:I3").EntireRow.Hidden = True
End If

If [E2].Value = NY Then
Range("A3:I3").EntireRow.Hidden = False
End If

If [E2].Value = WI Then
Range("A3:I3").EntireRow.Hidden = False
End If

End Sub

Thanks.

JJT
 
No change. Rows still don't unhide. Am I doing something wrong? I took out all of the IF statements in favor of the code you gave.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I ran this and it hid row 3

Code:
Sub test()
Range("A3:K3").EntireRow.Hidden = [E2].Value = ""
End Sub

I then entered a value in E2 and ran it again and it unhid row 3.
 
Upvote 0
It did not unhide the other rows. Also, I need them to unhide if certain criteria is met. Can I attach the workbook for you to see?
 
Upvote 0

Forum statistics

Threads
1,225,155
Messages
6,183,217
Members
453,151
Latest member
Lizamaison

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