Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i create chart like branch-sector sales & collections | Excel Discussion (Misc queries) | |||
How can I contact branch Office in Tokyo, Japan? | New Users to Excel | |||
How to write a macro?? | Excel Discussion (Misc queries) | |||
Establish a Branch of Clayton College here in Malaysia | Excel Worksheet Functions | |||
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? | Excel Worksheet Functions |