+ Reply to Thread
Results 1 to 7 of 7

Macro to find first row blank row then write in a formula

  1. #1
    Registered User
    Join Date
    07-17-2014
    Location
    Springfield, MO
    MS-Off Ver
    2007
    Posts
    42

    Macro to find first row blank row then write in a formula

    Hello Experts!

    I am attempting to write a macro that will locate the first row in column “D” that is blank and then write in this formula: "=SUMIFS([WebStats_Data_Pull.xlsm]Append_Data!C14,[WebStats_Data_Pull.xlsm]Append_Data!C3,C[-1],[WebStats_Data_Pull.xlsm]Append_Data!C1,C[-3],[WebStats_Data_Pull.xlsm]Append_Data!C2,C[-2])".

    I then need to copy it down to autofill to all cells below. I will need to do this for columns D, E and F. I am also getting stuck in the way that my formula currently references specific cells but the destination cell will always be different as it should be updating in the first blank row.

    This is the code that I have so far…

    Please Login or Register  to view this content.
    I really appreciate any help you are able to provide me! Thank you!
    Jbeets
    Last edited by jbeets; 09-22-2016 at 01:52 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to find first row blank row then write in a formula

    Hello jbeets,

    It is not so easy to see what you want to accomplish here:

    [/QUOTE] "=SUMIFS([WebStats_Data_Pull.xlsm]Append_Data!C14,[WebStats_Data_Pull.xlsm]Append_Data!C3,C[-1],[WebStats_Data_Pull.xlsm]Append_Data!C1,C[-3],[WebStats_Data_Pull.xlsm]Append_Data!C2,C[-2])". [/QUOTE]

    Are you referring to a different Workbook, or Sheet/s in the same Workbook?

    The Code you have is also incorrect, unless it could be a Mac requirement, which I am not familiar with. See the quotes in red below:

    Please Login or Register  to view this content.
    That should actually be:

    Please Login or Register  to view this content.
    Maybe it would be better if you could attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.


    Thank you.
    Last edited by Winon; 09-28-2016 at 03:49 PM.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    07-17-2014
    Location
    Springfield, MO
    MS-Off Ver
    2007
    Posts
    42

    Re: Macro to find first row blank row then write in a formula

    Thank you so much for taking the time to o read through my frustrating post. I hope that this is a little clearer...

    Here is the example file with what I am trying to accomplish.

    I don’t want to keep the formulas in the file since it will already be so big; I need this macro to go into the “Append_Data” tab, find the first empty cell starting in Column D and then enter the formula that I have provided. My issue is that if I type this formula in the macro, it is referencing a specific cell and would not be pointing to whatever cell is the first empty one.

    This example formula might be a better choice since it is referencing specific cells such as “C2”, “A2” or “B2”. So instead of each time the formula starting at in row 2 I need it to reference column A, B or C of whatever row contains the first blank cell in column D.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The formula is referencing two different workbooks to calculate the desired end product. The formula works perfectly; it is just the macro portion that is causing me frustration.

    Thank you again for any help you can provide.
    Jbeets
    Attached Files Attached Files
    Last edited by JBeaucaire; 09-30-2016 at 02:35 PM.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to find first row blank row then write in a formula

    Hello jbeets,

    I must admit that your request has me baffled, and I have asked other Forum Members to see if they can help.

    Let us hope a solution is on its way!

    Regards.

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

    Re: Macro to find first row blank row then write in a formula

    One way I deal with this is by NOT adding the formula myself, but by having that formula already existing in the needed column in row 2, and then simply copying down as new data is added. Something like this to get you started:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 09-30-2016 at 03:41 PM. Reason: Detect formulas in row 2
    _________________
    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!)

  6. #6
    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 find first row blank row then write in a formula

    I don't think you are referring too the sheet name properly.

    Please Login or Register  to view this content.
    Don't you mean?

    Please Login or Register  to view this content.

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to find first row blank row then write in a formula

    @JBeaucaire, and JOHN H. DAVIS,

    Thank you so much Jerry, that is the way to go!

    JOHN, that was exactly what I suspected as well!

    We should just mind the quotes:

    Please Login or Register  to view this content.
    You guys are Great!

    Once again, thank you for your help, time and support.

    Kind Regards.
    Last edited by Winon; 09-30-2016 at 03:37 PM.

+ 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] Macro to find blank cell paste vlookup formula
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2015, 12:35 PM
  2. Need to write VBA for find the st blank cell and add formula
    By Akatecho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2015, 05:17 AM
  3. Macro to find blank cell below B9 and input formula
    By iblac_788 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2013, 03:56 AM
  4. [SOLVED] macro loop through variable range to find blank, add formula
    By sammar12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2012, 11:39 AM
  5. Replies: 2
    Last Post: 02-17-2012, 03:08 AM
  6. Insert Blank Row-need to write macro
    By james598 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2009, 08:32 PM
  7. Replies: 12
    Last Post: 03-02-2009, 04:36 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