+ Reply to Thread
Results 1 to 5 of 5

multiple offset commands

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    multiple offset commands

    Hello. I'm just practicing coding and I was curious as to how you write multiple offset commands for moving around a sheet? Would I just repeat code below, or is there a more efficient way to do it?

    ActiveCell.Offset(0, 1).Select

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: multiple offset commands

    If you could post a sheet and explain what you want to do it would be better.

    Generally it's better not to select cells, it's not necessary and this makes the code run much slower.

    If you refer to specific sheets in your code then you can manipulate these cells without selecting them.

    Small example below, but post a sheet give me some examples of things you would like to do and I will help you.

    This will loop through the first 10 rows in the first column and add the value "Test" to all of them, it also sets the value in the cells 3 to the right to "New Test".

    The sheet doesn't have to be selected, nor do the cells.
    All of this is done on a sheet with the tab name of "One".

    I guess I should specify. If you refer to the sheet specifically you don't have to be on that sheet. If you don't refer to a sheet specifically the code will run on the cells in the currently active sheet, which might be okay, but if you or someone else runs the code and forget to switch to the sheet you want the code to manipulate you will have undesirable results.

    Referring to activecell can also cause issues if you activate the wrong cell or forget to activate the desired cell before starting the code.

    Please Login or Register  to view this content.
    Last edited by skywriter; 03-17-2015 at 05:16 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: multiple offset commands

    What do you mean by " moving around a sheet"
    Can you give examples
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: multiple offset commands

    Sure, it's just a simple exercise. Go from cell A1 to A3 to B7 to B9 to C18 etc. The order doesn't matter, the point is to just move around and understand the code.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: multiple offset commands

    See some possibilities attached.
    Test using F8 to go step by step
    Attached Files Attached Files

+ 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] VBA commands for multiple cells?
    By JLoKyM in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2013, 07:32 AM
  2. Multiple IF & +IF commands
    By simpleton58 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-29-2013, 01:37 PM
  3. Macro Recording Chart Format commands missing all important commands!!!!
    By nounours in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 09:20 PM
  4. Multiple Commands
    By jpxexcelforum in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2011, 04:37 AM
  5. Multiple If Commands
    By markswan20 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-17-2008, 05:54 PM

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