Run macro according to value of a cell

K

Kashyap

How to make a macro run automatically according to a value of a cell?

Eq: once we enter value '5' in cell G8, then a particular macro should run 5
times
 
H

Héctor Miguel

hi, !
How to make a macro run automatically according to a value of a cell?
Eq: once we enter value '5' in cell G8, then a particular macro should run 5 times

copy/paste (or type) the following in "that" worlksheet code module
(right-click its tab/name and choose: "viwe code")

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$G$8" Then Exit Sub Else Dim n As Byte
For n = 1 To Val(Range("g8"))
Macro1
Next
End Sub

hth,
hector.
 

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