Getting code to run!

Colleen45

Active Member
Joined
Jul 22, 2007
Messages
495
I have a problem getting this code to work

When ever one of the two names are selected the macro is supposed to run

code
Private Sub Worksheet_Change1(ByVal Target As Range)
If Target.Address(False, False) = "H6" Then
Select Case Target.Value
Case "Camps Bay", "Tokai": Call unhide_rows
End Select
End If
End Sub
/code
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The user has to select a name from a drop down list, and if one of those names are indicated in the maco (for the sake of simplicity only 2 names are indicated), then the macro should run automatically
 
Upvote 0
Yes it is from a data validation drop down.
with post 6 i suggested using a simpler way, if there is one, as this is proving somewhat of a nightmare
 
Upvote 0
If the event isn't firing there is no point in making any amendments. Does it fire when Z6 changes? Post the code you have now.
 
Upvote 0
This is all the code for this workbook that is currently there

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
With ActiveSheet
.PageSetup.PrintArea = "A1:BN" & .Range("T" & .Rows.Count).End(xlUp).Row
.PrintOut
.PageSetup.PrintArea = ""
End With
Cancel = True
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "Z6" Then
If Target.Value <> Target.Offset(-1).Value Or Target.Offset(-1).Value = "" Then
Application.EnableEvents = False
Target.ClearContents
Application.Goto reference:=Range("H6"), Scroll:=True
MsgBox "Please choose a value then enter the same in Z6", vbExclamation
Application.EnableEvents = True
End If
If Target.Address(False, False) = "H6" Then
Application.EnableEvents = True
Select Case Target.Value
Case "Camps Bay", "Tokai": Call unhide_rows
End Select
End If
End Sub
/code
 
Upvote 0
All of this code resides in "This Workbook" Module"
The Actual macro to "run" is in Modules,module1
 
Upvote 0
The Worksheet_Change procedure belongs in the module for the worksheet, not in the ThisWorkbook module. That's why it isn't firing.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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