+ Reply to Thread
Results 1 to 7 of 7

Removing Select statement to run code faster

  1. #1
    Registered User
    Join Date
    05-21-2014
    Posts
    32

    Removing Select statement to run code faster

    Hi,

    I have few queries,

    • I want to repeat this code for all sheets but without select statement it doesn't work, Is there any way to remove select statement here?

    Please Login or Register  to view this content.
    • I would like to couple the last 2 statements in to one. please help.
    Please Login or Register  to view this content.
    • Please see the attached file. I want to find the first row which contains 0 value. In this case it should return '5'.
    Attached Files Attached Files
    Last edited by wincross; 08-18-2017 at 09:59 AM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Removing Select statement to run code faster

    1. I'd do it like below (FYI - you have j = 1 to 4, but Next i ... this will cause issue).

    Please Login or Register  to view this content.
    I'm not sure what you are trying to do with your 2nd code... You are copying single row, but replicating that same row into multiple rows?
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    05-21-2014
    Posts
    32

    Re: Removing Select statement to run code faster

    Thanks for your reply.
    Rows (AF29:AG29) contains formula, just copying it to other lines. It works perfectly but I don't want select statement.
    Last edited by wincross; 08-18-2017 at 10:09 AM.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Removing Select statement to run code faster

    lol, ahem. "Robert A. Heinlein" is SF writer that wrote original Starship Troopers I'm just quoting him.

    In that case, I'd do something like below.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-21-2014
    Posts
    32

    Re: Removing Select statement to run code faster

    Thanks, Second point works great.
    Regarding first point, your code will work but I have many lines of coding (I mentioned that code for an example), I don't know how to bring all lines under With statement. Any other way?
    Any idea about my third query?

    Thanks again

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Removing Select statement to run code faster

    For your first question, hard to say without knowing your full code. Just remember to honor object model structure.

    Ex. All range belongs to some parent object, be it Sheet, Table etc.

    As for your 3rd question, depends. Is it fixed to Column C?

    You can try several methods.

    1. Application.Match (I'd recommend checking that x contains numeric value before further operation using ISNUMERIC function)
    Please Login or Register  to view this content.
    2. Range Find.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-21-2014
    Posts
    32

    Re: Removing Select statement to run code faster

    Thank you so much CK76.

+ 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. Faster/Cleaner way to Write IF OR Statement?
    By ExcelDavid in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-21-2016, 01:18 PM
  2. improving code by removing select
    By Zealotwraith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2013, 04:13 PM
  3. code to replace 'Rows("31:31").Select' statement with variables
    By Ed_Collins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2012, 06:28 PM
  4. Select Case code not returning correct statement
    By BCITgirl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2010, 01:15 AM
  5. Removing .Select to Improve Code Efficiency
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2010, 01:47 AM
  6. Code Procedure Problem: Exiting Select Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2010, 12:21 AM
  7. [SOLVED] VBA | Individual Iterations faster than Loop Statement
    By Butaambala in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2005, 08: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