View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Run macro only if Field E10 = "WO ID" and AB10 = "Spec Sizing"

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...
insertmodule
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

"ldiaz" wrote:

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

--
Lorenzo DÃ*az
Cad Technician