Macro not working properly on change in cell value

M

Monk

Hi

I am attempting to run a macro when there is a change in cell value.

The code in the worksheet is as follows:

Private Sub Worksheet_Change(ByVal Target As Range)



If Target.Address = "$c$1" Then Refresh1


End Sub

The code for the macro Refresh1 is

Sub Refresh1()
Application.ScreenUpdating = False
Application.Calculation = xlManual

ActiveSheet.ShowAllData

Range("A4:B2000").AdvancedFilter Action:=xlFilterInPlace, Unique:=True

Range("C4").Select
Application.Run "HideBlankRows"
Range("C1").Select
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub

Refresh1 works fine when running it via Tools/Macro/Macros however it
doesn't seem to work properly when there is a change in the cell value which
is supposed to run it automatically. It appears that the ShowAllData and
HideBlankRows commands are not working.

Any assistance to detect my error would be appreciated.

Thanks

Monk
 
P

Per Jessen

Hi

Your test is case sensitive.

Change to:

If Target.Address = "$C$1" Then Refresh1

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top