Macro's for dummies

Bananaramaman

New Member
Joined
Mar 21, 2002
Messages
4
Can someone please help out a relative beginner to excel. I would like to make a macro run automatically based on the value of a particular cell on the page. For example, if cell a1=1, then I want my macro named macro1 to run automatically. I am trying to tie this into a date. Can you please help and keep it in simple terms because like I said I am not an expert. Thank you in advance for any help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Can someone please help out a relative beginner to excel. I would like to make a macro run automatically based on the value of a particular cell on the page. For example, if cell a1=1, then I want my macro named macro1 to run automatically. I am trying to tie this into a date. Can you please help and keep it in simple terms because like I said I am not an expert. Thank you in advance for any help.

Hello,

What you need to do is this:

Right click your worksheet tab and choose View Code. This brings up the code sheet associated with that particular worksheet.

You can program Excel to run macros when certain things happen e.g. a cell changing value. If the value in A1 is typed in then you could use this:-

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A" Then
    If Target.Value = 1 Then Macro1
End If
End Sub

Where Macro1 would be in a standard module.

If the value in A1 is based on a formula which might change because of a non-cell changing entry (e.g. NOW()) then you'd probably be best using the Worksheet_Calculate event:-

Code:
Private Sub Worksheet_Calculate()
If Me.Range("A1") = 1 Then Macro1
End Sub

Hope that helps,
D
 
Upvote 0
On 2002-03-24 09:42, dk wrote:
The first procedure should be $A$1.

While you're in VBE, insert this script into another module:

Sub macro1()
MsgBox ("Hello world")
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,541
Latest member
iparraguirre89

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