![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Hi again,
Thank you for responses, I appreciate you taking the time to help. I notice from the examples posted the If, Then, Else Statement appears to draw a line under the Sub Routine and the conditions and in effect diverts to various other Sub Routines. I have code below a simple: If ActiveCell.Address = "$C$65536" Then Macro1 Things are not working too well .. it appears that it performs Macro1 if the condition is True and then Returns to the original code below the If statement and executes that. I am wondering if I therefore have to do an If, Then, Else with a False condition returning to another Subroutine to finish the procedure? I am sorry if I am making 'heavy weather' of this but it the end of a long week! Regards S. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Evening all,
I am currently trying to test to see if a Cell is, say C10 and if it is then 'branch' to another Subroutine. If the cell is not C10 I assume the If statement will be false and the 'original' macro will continue. Can anyone please give an example of an If statement. Many thanks in advance. S |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 33
|
something like this
if activecell=cells(10,3) then... might work, not sure... |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Quote:
Here is a simple example. Sub test() If ActiveCell.Address= "$C$10" Then test1 Else test2 End If End Sub Sub test1() MsgBox "TRUE" End Sub Sub test2() MsgBox "FALSE" End Sub |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Hi Jay,
Once again thanx for your response to my posting, that was just what I was looking for a simple explanation. I am looking to complete the Subroutine and NOT return to the original macro. I have incorporated the If statement and it appears to return to the original macro, there again it could be me! As usual any advice would be appreciated. Cheers. S |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
eg. If vbYes = MsgBox("Select YES to Goto [Sheet1]" & vbCrLf _ & "Select NO to Goto [Sheet2]", vbYesNo) Then Sheets("Sheet1").Select Else Sheets("Sheet2").Select End If End _________________ Kind Regards, Ivan F Moala http://<font color="green"><a href="...r Construction [ This Message was edited by: Ivan F Moala on 2002-04-12 15:04 ] |
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Hi All,
Sorry to be a pain but anyone got any ideas? Cheers S |
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
If ActiveCell.Address = "$C$65536" Then Macro1 Exit Sub End if This will break out of the routine. It will run Macro1, then return to this calling sub and then exit it. HTH, Jay |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|