Start a Macro from an "IF" Function

Emile_Ajar

New Member
Joined
Oct 13, 2010
Messages
4
Hello,

I have a formatting Macro I would like to be able to trigger automatically as soon as some numerical values populate the to be formatted columns. Is it possible? How can I do ?

Emile
 

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
Use Worksheet_Change event to monitor for your condition(s) and then have it call your macro.
 
Upvote 0
Thanks doofusboy,

This seems to be the clue, but...how do I use worksheet_change event ? Do I put it in the Macro itself ? Sorry to be such an ignorant :(
 
Upvote 0
Hi Again,

So this is what I tried out :

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveCell.Offset(0, -1).Columns("A:A").EntireColumn.Select
Selection.Copy
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(LEFT(RC[-1],8),"" "",RIGHT(RC[-1],1)+1)"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub

But its bugging and I dont have a clue why.
 
Upvote 0
trigger automatically as soon as some numerical values populate the to be formatted columns.
I have not tried out the code or anything but if by 'as soon as some numerical values populate' you mean being populated by the return of a/some formula(s), then you'll want to use the Worksheet_Calculate event instead of the Change event. (A change event isn't fired if the change you're referring to is a formula updating.)

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,215,540
Messages
6,125,409
Members
449,223
Latest member
Narrian

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