Execute a macro based a text in a column which is constantly changing by formulae

vijayamani1987

New Member
Joined
Mar 16, 2014
Messages
32
hi people,

Thanks in advance, and excuse me for my average English.

I am very new to VBA. I have a excel sheet, where cells in column B will change on predefined time frame, ex.5 minutes. I want to execute a macro when any cell in that column comes to have specific text, say YES. Please help me out with this.

Note: The values will change only by formula
 
Hi,
I see. Some how we have to distinguish new "execute" from the ones that are already processed. Can you add an extra column (e.g. column G) to your sheet so it can be used to mark those processed ones?
If the amount of data is not huge then a simple for-loop can loop through column B and look for "execute". Each time the value is "execute" we then should look in the help column and if there is no mark then your macro shall be executed.
Instead of the previous code in Calculate event of that sheet put this code in that event:
Code:
Dim Trows As Integer

Trows = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
'the help column is the G column
For m = 2 To Trows
 If ActiveSheet.Range("B" & m).Value = "Execute" And ActiveSheet.Range("G" & m).Value = "" Then
    MsgBox "This is a new execute"
    ActiveSheet.Range("G" & m).Value = "X" 'this is to mark the row as processed
    'here you can call your macro
 End If

Next m
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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