+ Reply to Thread
Results 1 to 6 of 6

Applying formula only to visible rows.

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Applying formula only to visible rows.

    I have some very complex formulas which I normally apply from the top available row (i.e. row 2) of column to the last row using the following code:

    Please Login or Register  to view this content.
    It works fine, however I would like to do the same for only the visible rows as advanced filtering may be used, I believe I would need such a loop:

    Please Login or Register  to view this content.
    The problem is that I am unable to convert the formula from step 1 (it is quite complex) to be used in step 2. Is there a method to have the formula from step 1 to be used in step 2?

    Thanks a lot.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Applying formula only to visible rows.

    in principle substitute the 2 (row #) for rngcell.row # and the 1 for rngcell.row-1 #
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Applying formula only to visible rows.

    Thanks rcm,

    Just to check, are you sure the correct syntax to replace
    Please Login or Register  to view this content.
    is
    Please Login or Register  to view this content.
    ?

    I now end up with the following formulas, though I end up with a runtime error 438 when running it:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Applying formula only to visible rows.

    Yes, rngcell.row will give the row in which rngcell resides, maybe that VBA can't handle so many variables.. before that try to see what string comes out of it since it is a string..

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Applying formula only to visible rows.

    I would suggest using FormulaR1C1 notation and then:
    Please Login or Register  to view this content.
    You may find correct formula string by selecting cell with current formula and entering
    Please Login or Register  to view this content.
    in Immediate Window. You must then double any quotation marks.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  6. #6
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Applying formula only to visible rows.

    Hi rcm,

    Not sure about the syntax you provided, it does not seem to work for a loop, even one which contains a very basic formula.


    Hi Izandol,

    You are spot on, the code seems to work perfectly and it is the easiest way for me to "transpose" my formulas already written. I just need to do a sanity check as the formulas are quite complex, but at first glance everything appear to work fine. Will close the thread once I have finished my check.

    Thanks a lot.

+ 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] applying a formula to many rows
    By Vogelmann in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2012, 08:03 AM
  2. [SOLVED] Applying code only to visible cells
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2012, 11:07 AM
  3. Use visible rows from autofilter to build Pivot table. Or use visible rows to Copy/Paste
    By mwhitedesigns in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 10:34 AM
  4. Replies: 8
    Last Post: 07-14-2012, 10:22 AM
  5. Applying Formulas to Visible Cells Only
    By SteveC in forum Excel General
    Replies: 7
    Last Post: 06-26-2006, 06:50 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