+ Reply to Thread
Results 1 to 4 of 4

need help with VBA code for moving though designated calls automatically

Hybrid View

nicody need help with VBA code for... 09-24-2019, 10:13 PM
AlphaFrog Re: need help fixing error 09-24-2019, 11:45 PM
nicody Re: need help fixing error 09-26-2019, 05:41 PM
Pepe Le Mokko Re: need help fixing error 09-25-2019, 03:01 AM
  1. #1
    Registered User
    Join Date
    05-07-2018
    Location
    ontario, canada
    MS-Off Ver
    standard 2019
    Posts
    56

    need help with VBA code for moving though designated calls automatically

    Hi,

    I got some code from a previous thread and it has worked beautifully.

    Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub 'multiple cells changed If Not Intersect(Target, Range("A3:A300")) Is Nothing Then Application.Goto Target.Offset(0, 2) End If If Not Intersect(Target, Range("C3:C299")) Is Nothing Then Application.Goto Target.Offset(1, -2) End If End Sub
    I tried to adapt it for another worksheet that I am creating but seem to keep getting an error.

    This is how I changed it:

    Private Sub Worksheet_change(ByVal target As Range) 'to move through appropriate cells If target.Cells.Count > 1 Then Exit Sub 'multiple cells changed If Not Intersect(target, Range("a3:a1000")) Is Nothing Then Application.Goto target.Offset(0, 3) End If If Not Intersect(target, Range("d3:d1000")) Is Nothing Then Application.Goto target.Offset(0, 2) End If If Not Intersect(target, Range("f3:f999")) Is Nothing Then Application.Goto target.Offset(1, -5) End If
    It is Run-time error '1004':

    application-defined of object-defined error
    on the last line --Application.goto target.Offset(1, -5)

    and it is not cycling through the cells, it is just going down to the next row.

    I want to enter a number in A2 and have it go to cell D2, then F2 then A3 and so on after a value is entered in each cell.

    Can anyone fix this for me please. Thanks in advance.
    Last edited by nicody; 09-26-2019 at 05:29 PM. Reason: revising title

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: need help fixing error

    Private Sub Worksheet_Change(ByVal Target As Range)
    'to move through appropriate cells
        If Target.Cells.Count > 1 Then Exit Sub    'multiple cells changed
        If Not Intersect(Target, Range("a3:a1000")) Is Nothing Then
            Application.Goto Target.Offset(0, 3)
        ElseIf Not Intersect(Target, Range("d3:d1000")) Is Nothing Then
            Application.Goto Target.Offset(0, 2)
        ElseIf Not Intersect(Target, Range("f3:f999")) Is Nothing Then
            Application.Goto Target.Offset(1, -5)
        End If
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    05-07-2018
    Location
    ontario, canada
    MS-Off Ver
    standard 2019
    Posts
    56

    Re: need help fixing error

    Thanks, that works great!!

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: need help fixing error

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

+ 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] Fixing runtime error '53'
    By Bronx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-03-2016, 09:28 AM
  2. [SOLVED] Index range fixing error
    By silambarasan.J in forum Excel General
    Replies: 4
    Last Post: 01-27-2016, 06:44 AM
  3. Fixing Date Error -
    By JCL622 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-07-2013, 10:54 AM
  4. [SOLVED] Help me in fixing the error
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-26-2012, 07:26 AM
  5. [SOLVED] Fixing a sorting error for empty rows (error '1004')?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:20 PM
  6. Fixing a sorting error for empty rows (error '1004')?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:17 PM
  7. Fixing the #DIV/0! Error
    By kc2equ in forum Excel General
    Replies: 1
    Last Post: 02-22-2005, 11:32 PM

Tags for this Thread

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