+ Reply to Thread
Results 1 to 7 of 7

Speeding up For loop

  1. #1
    Registered User
    Join Date
    12-06-2014
    Location
    Manchester, UK
    MS-Off Ver
    2010
    Posts
    5

    Speeding up For loop

    Hi everyone, does anyone know a way to speed this up?

    Please Login or Register  to view this content.

    I thought about this:
    Please Login or Register  to view this content.
    But I have a huge spreadsheet that is already in A1 formula formatting that would take days to swap over. I'm not aware of a way to use both types at the same time?


    Thanks,

    Ryan
    Last edited by ryanarbabi; 12-06-2014 at 11:07 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Speeding up For loop

    Ryan

    You wouldn't need to change your spreadsheet to use R1C1 to use the second set of code.

    The formulas will be appear in whatever notation the sheet is set up to use.

    Mind you this should work too.
    Please Login or Register  to view this content.
    PS Can you add code tags when posting code?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Speeding up For loop

    Quote Originally Posted by ryanarbabi View Post
    I thought about this:
    Range("Q10:Q209").FormulaR1C1 = "=IF(RC[-15]=0,"",RC[-15])"
    Range("P10:P209").FormulaR1C1 = "=IF(RC[-13]=0,"",RC[-13])"
    It would work if you doubled the double-quotes for the null string, as you did in the for-loop. To wit:

    Range("Q10:Q209").FormulaR1C1 = "=IF(RC[-15]=0,"""",RC[-15])"
    Range("P10:P209").FormulaR1C1 = "=IF(RC[-13]=0,"""",RC[-13])"

    But I would prefer to write:

    Range("Q10:Q209").Formula = "=IF(B10=0,"""",B10)"
    Range("P10:P209").Formula = "=IF(C10=0,"""",C10)"

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Speeding up For loop

    Oops, forgot to double up on the quotes.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Speeding up For loop

    Sub ryanarbabi()
    With Range("P10:P209")
    .Formula = "=IF(RC[-13]=0,"""",RC[-13])"
    .Offset(, 1).Formula = "=IF(RC[-15]=0,"""",RC[-15])"
    End With
    End Sub

    @ Norie. It's a weekend Norie.

    @ Norie again.
    Now that we've got you on the line, when I use the Formulae you suggested, with the double quotes, it'll come out like this:
    Please Login or Register  to view this content.
    It has an apostroph in front and at the end of the cell references.
    However, when I leave the R1C1 out, it's OK
    That must be because of the R1C1. I have never seen this before but then I never use the R1C1 in a formula.
    Is there a logical explanation for this Norie?
    Last edited by jolivanes; 12-06-2014 at 07:05 PM.

  6. #6
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Speeding up For loop

    [.... deleted; redundant ....]
    Last edited by joeu2004; 12-06-2014 at 09:47 PM.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Speeding up For loop

    Don't mix your A1 and R1C1 notation, it's a recipe for disaster.

+ 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. Help speeding up a for loop
    By msfarrar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2012, 02:52 PM
  2. [SOLVED] Speeding up loop code
    By Mrowe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2012, 11:43 AM
  3. speeding up a loop
    By menos in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-08-2011, 09:49 AM
  4. Speeding up VBA
    By smurray444 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2007, 09:55 AM
  5. Speeding up the Execution of an SQL query in a VBA loop?
    By gimiv in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2007, 03:31 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