+ Reply to Thread
Results 1 to 3 of 3

How to control cursor with variable input values

  1. #1
    Registered User
    Join Date
    03-22-2014
    Location
    Vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    How to control cursor with variable input values

    Hi Guys and Gals,
    I was wondering if someone could point out the obvious for me while I still have some hair left.
    Within a macro, I am trying to move the cursor down variable amount of rows. I would like to input the value of how many times the cursor should move down into a cell (for example into “D1”).

    So as an example, in the following code, I would like to replace the “99” with a variable value in cell D1. I am sure you guys can answer this in your sleep, but I just can’t figure out the formatting for the ActiveCell.Offset command.

    Range("A1").Select
    ActiveCell.Offset(99, 0).Rows("1:1").EntireRow.Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    ActiveCell.Offset(99, 0).Rows("1:1").EntireRow.Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Select

    Any help would be greatly appreciated.

    Thank-you for your time,
    Pete.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to control cursor with variable input values

    ????????Once you put 99 in cell D1, the activecell becomes D2, so you want to move the cursor down to D101 ??
    Gary's Student

  3. #3
    Registered User
    Join Date
    03-22-2014
    Location
    Vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How to control cursor with variable input values

    Thanks for replying Jakobshavn,

    I received an answer at another forum, and all I needed to do was use the Range("D1") command instead of "99" to use the value in D1.

    My original request may not have been that clear, but I wanted the cursor to move an "x" rows down as specified in cell D1. It works now using the Range(D1) so the code in question looks like this :

    ActiveCell.Offset(Range("D1"), 0).Rows("1:1").EntireRow.Select

    Thank-you for your time and effort.

    Cheers, Pete.
    Last edited by Petrocelli99; 03-22-2014 at 02:07 PM.

+ 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. controlling excel input move cursor right, then down
    By lippywon in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2012, 03:17 AM
  2. Cursor movement control in excel.
    By fanku in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2011, 04:10 AM
  3. Excel 2007 : Cursor Control
    By Robin G in forum Excel General
    Replies: 3
    Last Post: 02-13-2009, 01:08 PM
  4. how I can have the cursor return to the input field
    By barrington in forum Excel General
    Replies: 3
    Last Post: 03-01-2007, 11:59 PM
  5. Control cursor direction in highlighted group of cells/Page setup
    By George Tung in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 09-06-2005, 07:05 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