Executing Macros Automatically

gbwcf

New Member
Joined
Oct 16, 2002
Messages
6
I have a list box in my workbook. Is there a way to have a macro run automatically when a selection is made in the list box?

Thank you.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Chas 17 how would i make the following macro run automatically?


Sub B_2()


If [A1].Value = "1" Then
MsgBox "Incomplete Invoice, please complete the following before saving." + vbCrLf + "" + vbCrLf + " Customer Reference, Invoice Number & Price.", VBINFO, " B_2 "
End If


End Sub
 
Upvote 0
hey mate, just searching to see if you had posted anything lately - you could set this up so that an event triggers your macro, such as a change event or a calculation event. question: is the contents of A1 a formula, or is a value that has to be manually entered? this will affect what kind of event you would use to trigger your macro. let me know

kevin
 
Upvote 0
just insert this into your sheet module where this entry takes place by right clicking on the sheet tab and selecting 'view code':

Code:
Private Sub Worksheet_Change(ByVal Target as Range)
If Target.Address <> "$A" Then Exit Sub
If [A1].Value = "1" Then 
MsgBox "Incomplete Invoice, please complete the following before saving." + vbCrLf + "" + vbCrLf + " Customer Reference, Invoice Number & Price.", VBINFO, " B_2 " 
End If 
End Sub

take care
kevin
 
Upvote 0
I tried kskinne code but did not work, did I misunderstand? Opps, code will work, missing a 1 for cell A1...
Manually input a 1 in cell a1 to cause auto display of msg?
I have Excel 97 at work, chas17
this also works
chas17:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Set vrange = Range("a1")

For Each cell In Target
If Union(cell, vrange).Address = vrange.Address Then
If [A1].Value = "1" Then
MsgBox "Incomplete Invoice, please complete the following before saving." + vbCrLf + "" + vbCrLf + " Customer Reference, Invoice Number & Price.", VBINFO, " B_2 "
End If
End If
Next cell

End Sub
This message was edited by Chas17 on 2002-10-24 16:12
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

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