+ Reply to Thread
Results 1 to 8 of 8

VBA 'GoTo' Buttons by variable increment

  1. #1
    Registered User
    Join Date
    08-24-2014
    Location
    Edmonton, Alberta
    MS-Off Ver
    2016-64 bit & Win 10
    Posts
    8

    VBA 'GoTo' Buttons by variable increment

    My query is detailed on the attached sheet, but in a nutshell ...

    I have buttons that sent the cursor to different places in the 'A' column, by a step that was inserted in the coding (100, 200, 300, ...)

    (The button labels are determined by the first three letters in a cell of that row, but that seems to be under control)

    My wish is to make that step flexible, by having it reference a cell, so steps could be 125, or 150, or whatever.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA 'GoTo' Buttons by variable increment

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-24-2014
    Location
    Edmonton, Alberta
    MS-Off Ver
    2016-64 bit & Win 10
    Posts
    8

    Re: VBA 'GoTo' Buttons by variable increment

    Thank You Leo ...

    This seems to be the code to do what I'm already doing ... here's what I've got -

    Sub GoTo_A1017()
    '
    'GoTo_A1017 Macro
    '

    '
    Application.Goto Reference:="R1017C1"
    End Sub

    Sub GoTo_A2017()
    '
    'GoTo_A2017 Macro
    '

    '
    Application.Goto Reference:="R2017C1"
    End Sub

    I'm looking to make the 'R1017 & R 2017' step by a variable, rather than by the 'thousands I have 'hard coded' into the macro.

    The value would be calculated as

    reference;="R(17+Step_By*1)C1" and reference;="R(17+Step_By*2)C1"

    I don't know how to incorporate that 'Step_by' variable into the row reference.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA 'GoTo' Buttons by variable increment

    So, and where do we find this variable ?

  5. #5
    Registered User
    Join Date
    08-24-2014
    Location
    Edmonton, Alberta
    MS-Off Ver
    2016-64 bit & Win 10
    Posts
    8

    Re: VBA 'GoTo' Buttons by variable increment

    It would be in a cell named "Step_By" which is D1 in my example

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA 'GoTo' Buttons by variable increment

    so change this A4, A7, and A10 to D1

  7. #7
    Registered User
    Join Date
    08-24-2014
    Location
    Edmonton, Alberta
    MS-Off Ver
    2016-64 bit & Win 10
    Posts
    8

    Re: VBA 'GoTo' Buttons by variable increment

    OK I see ... I'll start in on that directly. Thank you

  8. #8
    Registered User
    Join Date
    08-24-2014
    Location
    Edmonton, Alberta
    MS-Off Ver
    2016-64 bit & Win 10
    Posts
    8

    Re: VBA 'GoTo' Buttons by variable increment

    Here's the code that is doing what I was looking for ...

    Sub GoTo_Step01()
    Application.Goto Range("A" & 17 + 0 * Range("Step_By").Value)
    End Sub

    Thanks for the education on getting formulas and variables into VBA ... should help me in the long run.

    Stay Well

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Make variable Goto command
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2018, 10:15 AM
  2. On Error goto Variable
    By shaykos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2017, 02:31 PM
  3. [SOLVED] Goto a section with Variable
    By nironto in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-14-2016, 11:45 AM
  4. Convert Variable and use in GoTo statement
    By stuartgb100 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-27-2015, 10:49 AM
  5. [SOLVED] GOTO sucks, but can I "GOTO Variable"?
    By smpita in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-25-2014, 03:14 PM
  6. Buttons to increment adjacent cell values
    By jaskamakkara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2013, 12:43 PM
  7. Trying to find better way of 'goto' variable label
    By phillipe124 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2011, 10:11 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1