Run macro only if Field E10 = "WO ID" and AB10 = "Spec Sizing"

  • Thread starter Thread starter ldiaz
  • Start date Start date
L

ldiaz

hello all.

I want to run a macro only:
if Field E10 = "WO ID" and AB10 = "Spec Sizing"

if fields are different then it must show a message saying that the file is
not the correct one.

my macro needs Ctrl + m key to run,

and start llike this:

Sub Shipping()
' Keyboard Shortcut: Ctrl+m
'start Macro
Statement
'End macro
End Sub

where do I need to put the code?


please help
Thanks in advanced
 
hi
to run, the macro must be in an open file.
put it in a general module in the file that you will be running the macro.
open the vb editor....Alt+F11
if the code window (big one, far right) is gray....
on the tool bar...
insert>module
paste your code in the code window. save the file.

Sub yoursub()
if range("E10").value ="WO ID" and range("AB10").value = "Spec Sizing" then
your code here
else
msgbox "wrong file!"
end if
end sub

alter possiblity....
Sub yoursub()
if activeworkbook.name = yourworkbookname then
your code here
else
msgbox "wrong file!"
end if
end sub

regards
FSt1
 

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

Back
Top