Calling a macro on worksheet_change

tweek

Board Regular
Joined
Jun 16, 2006
Messages
104
Hi, I´m having problems calling a macro.

Private Sub Worksheet_Change is located in sheet1

with the following code:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$c$5" Then
Call Macro3
End If

End Sub



Macro3 is located in Module2 in the same workbook and works fine on its own with the following code:


Sub Macro3()
'
' Macro3 Macro
'
NewName = Range("c5").Value
name2 = Range("c6").Value
name3 = Range("c7").Value
ActiveSheet.Name = NewName & "_" & name2 & "_" & name3
End Sub



Nothing happens when I enter a valur into cell c5, any ideas what I´m doing wrong?
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Nogslaw

Well-known Member
Joined
Jul 9, 2004
Messages
904
The address is case sensitive. Change it to:

Code:
If Target.Address = "$C$5" Then
 

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
As Target is a Range try:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("C5") Then
Call Macro3
End If
End Sub

Dom
 

tweek

Board Regular
Joined
Jun 16, 2006
Messages
104
thanks for the fast reply.. this works for me. I didn´t realize it would be case sensitive.

thanks again :)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,773
Messages
5,598,010
Members
414,202
Latest member
tejprn

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
Top