Run Macro automatically

albatross32

New Member
Joined
Feb 17, 2010
Messages
32
I am a VBA novice but want to use;

Private Sub Worksheet_Change(ByVal Target As Range)

In Range S3:S232 all cells are empty.

Formulas within the Worksheet will lead to "1" being entered into one cell at a time in the Range S3:S232.

When that happens I want a two second time delay and then a "1" to be entered in column V of the same row. The existing formulas will not allow another S cell to change until the V cell has changed.

I need the function to remain open so that all the time the Worksheet is activated everytime one of the S cells change the V cell of the same row changes after a two second time delay.
 
How about using the Worksheet_Calculate rather than worksheet change that way it activates everytime a formula calculation occurs.
Something like this:

Code:
Private Sub Worksheet_Calculate()
Dim icell As Range
 
For Each icell In Range("S3:S232")
    If icell.Value = "1" Then
        Application.Wait (Now + TimeValue("0:00:02"))
        icell.Offset(0, 3).Value = "1"
    End If
Next icell
 
End Sub
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I found out about Worksheet_Calculate late last night after further trawling through various Excel forums.

But many thanks to you for preapring the correct VBA code for my application. I have not had the opportunity to run your code as yet but am hopeful because initial working with Worksheet_Calculate shows it appears to do what I want.

Many thanks again for your time and consideration.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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