Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Toronto, CANADA.
    Posts
    292
    Thanks
    21
    Thanked 3 Times in 3 Posts

    GO TO (Office 2003-SK1)

    Hi All;

    I am looking to find a command which will re-direct the current address as a consequence of a logic command.
    I am old enough to try to assimilate this query to what the GO TO command was in Fortran IV programming.
    In essence, I would like to have in a cell the formula =IF(C3<0, GO TO C4, GO TO C5).
    Kind of branching, I would say.
    Could someone please help?
    BTW, I don't know VB, I would like to have the knowledge to apply this in Excel.

    Thanks a lot in advance.

    Daniel Rozenberg.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: GO TO (Office 2003-SK1)

    Are you looking to have the cell with the formula take different values based on the contents of C3? If so in the cell enter the formula:
    =if(c3<0, C4,C5)

    If you want the active cell to switch to C4 or C5 depending on what you enter into C3 you will have to do it with a macro. Something like this added to the worksheet object in VB

    <pre>Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("C3")) Is Nothing Then
    If Range("C3").Value < 0 Then
    Application.Goto Range("C4")
    Else
    Application.Goto Range("C5")
    End If
    End If
    End Sub</pre>


    If neither is what you are after, could you elaborate?

    Steve

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Toronto, CANADA.
    Posts
    292
    Thanks
    21
    Thanked 3 Times in 3 Posts

    Re: GO TO (Office 2003-SK1)

    Thank you very much for your reply.
    I want the active cell to switch to C4 or C5 depending on the logical outcome of the formula.
    I believe your macro does it. I tried to copy it and paste it, but it didn't work. I am not handy in VB.
    I will try other way to get the objective.
    Nevertheless, thanks again.
    Daniel Rozenberg.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: GO TO (Office 2003-SK1)

    Perhaps you didn't copy the macro properly. Try this:
    - Select Steve's code.
    - Press Ctrl+C to copy it.
    - Activate Microsoft Word.
    - Press Ctrl+V to paste the code.
    - Select the code again.
    - Press Ctrl+C to copy it. (Yes, this is necessary!)
    - Activate the worksheet.
    - Right-click the sheet tab.
    - Select View Code from the popup menu.
    - Press Ctrl+V to paste the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •