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?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
The address is case sensitive. Change it to:

Code:
If Target.Address = "$C$5" Then
 
Upvote 0
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
 
Upvote 0
thanks for the fast reply.. this works for me. I didn´t realize it would be case sensitive.

thanks again :)
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,382
Members
448,889
Latest member
TS_711

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