Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Write a branch to another macro

I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 897
Default Write a branch to another macro

Sub MyMacro()

If Worksheets("mysheet").Range("B7").Value = 1 Then
Call Macro1
ElseIf Worksheets("mysheet").Range("B7").Value = 2 Then
Call Macro2
Else MsgBox "Incorrect Entry"
End If

End Sub


HTH,
JP

On Apr 9, 8:01*pm, iashorty
wrote:
I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Write a branch to another macro

Select case worksheets("sheet1").range("b7").value
case is = 1
call NameOfMacroA
case is = 1
call NameOfMacroB
case else
msgbox "incorrect entry"
end select

Use the name of the macro--not the shortcut key.

iashorty wrote:

I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Write a branch to another macro

change that second "case is = 1" to "case is = 2".

Dave Peterson wrote:

Select case worksheets("sheet1").range("b7").value
case is = 1
call NameOfMacroA
case is = 1
call NameOfMacroB
case else
msgbox "incorrect entry"
end select

Use the name of the macro--not the shortcut key.

iashorty wrote:

I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Write a branch to another macro

hi
if Range("B7").value = 1 then
Call macro1
else
if range("B7")= 2 then
Call Macro2
else
msgbox "Incorrect entry"
exit sub
end if
end if

regards
FSt1

"iashorty" wrote:

I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Write a branch to another macro

Thank you everyone. You are all very helpful.
IAShorty

"iashorty" wrote:

I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".

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
how do i create chart like branch-sector sales & collections Gnana Prasad Excel Discussion (Misc queries) 1 January 11th 08 08:00 AM
How can I contact branch Office in Tokyo, Japan? newbird New Users to Excel 0 May 21st 06 03:19 PM
How to write a macro?? Keeter Excel Discussion (Misc queries) 1 July 19th 05 08:34 PM
Establish a Branch of Clayton College here in Malaysia Datuk Dr. Mat Lazim Excel Worksheet Functions 2 July 8th 05 11:32 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 04:15 AM.

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"