+ Reply to Thread
Results 1 to 10 of 10

Macro to copy formula to blank cells in a dynamic range

  1. #1
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Macro to copy formula to blank cells in a dynamic range

    Hi ,

    I have this macro to copy the formual in a certain cell (F1 in the example below) to all blank cells in a range

    Please Login or Register  to view this content.
    There are three problems:

    1. if the range contains no blank cells I recive a warning "no blank cells" and the full range stays marked - resulting in the formula in F1 to be copy over all cells.
    2. the range change so in the macro I need to refer to a dynamic range and I don't know how?
    3. I run the above macro for several colums (F,G,H,I,J and K) - It would be great if one macro could do this for all colums in once. (the number of rows won't change between colums). I could to this by just copy the code within the macro and paste it for each colum but I bet there are a more fancy way of doing this :-)

    Thanks in advance for your help!
    Last edited by masben; 02-25-2013 at 07:07 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to copy formula to blank cells in a dynamic range

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Macro to copy formula to blank cells in a dynamic range

    Hi John,

    Thanks for your reply - I havn't tried it yet but it looks like it lacks a feature that I need. I wan't clear enough about this so its my fault - the blank cell in each colum should be replaced by the formula in row 1 in that colum. So in Col F it's the formula in F1 in col G it's the formula in G1 and so on... Do you think it's possible to modify your code to meat this?

    Thanks agian,
    Martin

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to copy formula to blank cells in a dynamic range

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Macro to copy formula to blank cells in a dynamic range

    masben, it seems almost like you are copying the Table function in Excel.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  6. #6
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Macro to copy formula to blank cells in a dynamic range

    Thanks John!

    Tha macro works like a charm! Perfect.

    All the best
    /Martin

  7. #7
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Macro to copy formula to blank cells in a dynamic range

    Hi Jacc,

    How do you mean? - I like to learn :-)

    /martin

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to copy formula to blank cells in a dynamic range

    Quote Originally Posted by masben View Post
    Thanks John!

    Tha macro works like a charm! Perfect.

    All the best
    /Martin
    You're welcome. Glad to help out, and thanks for the feedback.

  9. #9
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Macro to copy formula to blank cells in a dynamic range

    I made a simple table here. Just fill in new numbers in the Diameter and Height columns and it will copy the formulas automatically.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    11-20-2012
    Location
    stockholm
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Macro to copy formula to blank cells in a dynamic range

    Quote Originally Posted by Jacc View Post
    I made a simple table here. Just fill in new numbers in the Diameter and Height columns and it will copy the formulas automatically.
    Thanks Jacc,

    It's not exactley what I needed this time but very useful and will come well in hand other times.

    Cheers,
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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