+ Reply to Thread
Results 1 to 7 of 7

Activecell.offset alternative

  1. #1
    Registered User
    Join Date
    07-05-2016
    Location
    Nottingham
    MS-Off Ver
    2010
    Posts
    12

    Activecell.offset alternative

    Hi,

    I'm developing a spreadsheet which is looking at over 500 rows. Depending on a marker hidden in a column of each row, the code decides what it is going to do with a row. For example, Insert a row underneath, hide it, clear it's contents etc.

    Using activecell.offset to move to each row to analyse what to do it with, I believe is causing the procedure to run incredibly slowly.

    Is there an alternative that can be used other than physically moving to each row at a time? I basically need to get this routine running faster!

    I'm a novice at this - you may have gathered!

    Thanks for all your help.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activecell.offset alternative

    Absolutely what you're describing can be more efficient. The goal is to minimize the number of times a physical change is made to the worksheet.

    So, if you're going to be deleting some rows, a routine that goes through and collects all the rows to be deleted, then deletes them all at once at the end, would be superiorto one that deleted rows one at at time.

    If you're going to be hiding rows, a second routine to do that afte the first is done deleting can be used to hide a collection of rows all at once.

    Finally, if you're going to be clearing entire rows, the same technique can be used a third time to collect the rows to clear, then do it all at once at the end.


    If you provide the following I can help more specifically:

    1) The column to evaluate
    2) The first row of data (often row1 or more are headers that need to be ignored)
    3) A list of the values and what do for each
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-05-2016
    Location
    Nottingham
    MS-Off Ver
    2010
    Posts
    12

    Re: Activecell.offset alternative

    Thanks for your help.

    This isn't going to be mega easy to explain. A worksheet is being built from another worksheet in the workbook, but the new worksheet require formatting, rows hiding etc depending on the markers in the column. The markers for ease of explanation are in column D.

    If there is a '0' in D and the cell in E isn't blank, the row needs auto fitting to height and then moving down for the next row to be analysed.

    If there is a number, 1 to 15 in column D and E isn't blank, the row needs auto fitting to height and a new row inserting underneath.

    If there is a number 1 to 15 in column D and E is blank, the contents require clearing and the row hiding.

    I assume the code for each would be relatively similar. There are around 550 rows to analyse.

    Does any of that make sense?

    Thanks again.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activecell.offset alternative

    Add what is the criteria for deleting rows?

    Also, why are we clearing the contents of a row and then hiding it instead of simply removing the unwanted row?

  5. #5
    Registered User
    Join Date
    07-05-2016
    Location
    Nottingham
    MS-Off Ver
    2010
    Posts
    12
    Quote Originally Posted by JBeaucaire View Post
    Add what is the criteria for deleting rows?

    Also, why are we clearing the contents of a row and then hiding it instead of simply removing the unwanted row?
    No rows require deleting, just hiding.

    Formula on another spreadsheet is relying on there being a set number of rows. It's complicated! :-)

    The contents require clearing as there are certain ranges which are using the countA function. Hidden rows need to be clear.

    The 'template' data is ever changing which is why it has to be done this way. Some rows hidden on one build, may not be on another. Another worksheet analyses the data on this sheet to generate reports.

    Does that make any sense??

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Activecell.offset alternative

    Something like this to demonstrate the technique and you can tweak from there:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-05-2016
    Location
    Nottingham
    MS-Off Ver
    2010
    Posts
    12

    Re: Activecell.offset alternative

    Hi,

    This has helped me learn loads. Thanks so much!

    I have used the code as you have shown, it has sped things up, but the routine is still running a little slowly unfortunately. I will have to look into it further, but this is such a better way of doing it rather than activecell.offset!

    You have been really helpful, thanks again.

+ 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] SpeedUp/Alternative to Offset.Value = Offset.Value
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 01:43 AM
  2. [SOLVED] VBA ActiveCell Offset
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2013, 05:50 AM
  3. activecell offset without vba?
    By AverageCanadian in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-11-2013, 03:59 PM
  4. activecell.offset
    By steelsoul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2010, 09:23 AM
  5. ActiveCell.Offset via Dim
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2007, 11:13 PM
  6. ActiveCell Offset
    By rnrss in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-07-2005, 05:12 AM
  7. [SOLVED] Activecell offset value with formula?
    By Dave in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2005, 09:05 AM
  8. activeCell.offset in another worksheet
    By François in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2005, 06:06 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