Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Run macro only if Field E10 = "WO ID" and AB10 = "Spec Sizing"

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Run macro only if Field E10 = "WO ID" and AB10 = "Spec Sizing"

That's great,
it works perfectly


Thanks

--
Lorenzo DÃ*az
Cad Technician


"FSt1" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run macro only if Field E10 = "WO ID" and AB10 = "Spec Sizing" ldiaz Excel Discussion (Misc queries) 2 March 15th 08 07:26 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"