+ Reply to Thread
Results 1 to 5 of 5

Excel Macro: Fill Blank Cells with Respect to No. of Rows

  1. #1
    Registered User
    Join Date
    03-01-2017
    Location
    Manila, Philippines
    MS-Off Ver
    MS Office 2007
    Posts
    77

    Excel Macro: Fill Blank Cells with Respect to No. of Rows

    Hi ExcelForum Experts,

    Please see attached workbook as reference.

    I am wondering if someone could help me with the flexible codes which will only capture the data in a certain table. I have a monthly data with fluctuating number of rows and I am having a hard time creating a macro codes that will only select range of cells based on the number of rows of column F (please see attached workbook). The macro code that I have recorded is only applicable to the attached workbook with "46" number of rows. If I have "75" number of rows next month and "105" number of rows or more on the following months, the said macro codes will not work unless I adjust the range.

    Let me know should you need additional details. Have a nice day ahead!

    Warmest regards,
    Arnel
    Attached Files Attached Files

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Excel Macro: Fill Blank Cells with Respect to No. of Rows

    hi Arnel. you have 2 modules, so which are you referring to. if it's 46 rows, i'm assuming it's module 1. to edit the code, press ALT + F11 to access the VBA window. press CTRL + R if you don't see the project Explorer on the left. double-click Module 1 there to edit it.

    this code below helps you obtain the last row. based on your data, i can use column E or F to determine the last row since they have no empty cells. so:
    Please Login or Register  to view this content.
    Rows.count will count the total number of rows in Excel. in xlsm, it will be 1 million over. in xls, it will be 65000 over. from the total rows, it then finds the last filled row on top. that will bring you to row 46 in this case. with that, you can change your codes to:
    Please Login or Register  to view this content.
    do the same for all row 46.

    another tip. while recording, you would have scrolled here and there. remove them to make your codes cleaner and run faster.
    Please Login or Register  to view this content.
    and if you ever see a .select, try to combine the next code with it. if you fail, simply revert it back. for eg.
    Please Login or Register  to view this content.
    this could be reduced to:
    Please Login or Register  to view this content.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,575

    Re: Excel Macro: Fill Blank Cells with Respect to No. of Rows

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-01-2017
    Location
    Manila, Philippines
    MS-Off Ver
    MS Office 2007
    Posts
    77

    Re: Excel Macro: Fill Blank Cells with Respect to No. of Rows

    Hi benishiryo,

    It works like magic!

    Thanks for your help especially for the tips that made my understanding better. I really appreciate the way you interpret the codes because it helps me understand how it works.

    Once again, thank you and have a blessed day ahead!

    Warmest regards,
    Arnel :-)

  5. #5
    Registered User
    Join Date
    03-01-2017
    Location
    Manila, Philippines
    MS-Off Ver
    MS Office 2007
    Posts
    77

    Re: Excel Macro: Fill Blank Cells with Respect to No. of Rows

    Hi Jindon,

    Thanks for your quick feedback and inputs. I will also try those codes and try to understand how it works.

    Have a wonderful day! Cheers!

    Warmest regards,
    Arnel :-)

+ 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 fill blank cells in column A based on non-blank cells
    By ktalamantez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2014, 02:47 PM
  2. Auto fill worksheet cells based on certain criteria w/out leaving blank rows.
    By Txprospector in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-10-2014, 07:35 AM
  3. Macro to select rows with respect to highest value in column
    By gokzee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2012, 09:41 PM
  4. macro to fill blank cells by above value
    By sandiptemkar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2012, 07:28 AM
  5. macro to fill blank cells with location
    By kellen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-24-2010, 07:52 PM
  6. Macro to fill in blank cells
    By ChrisF79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2008, 02:41 PM
  7. Macro to Fill Blank Cells
    By floridagunner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2007, 04:50 PM
  8. macro copy fill the in-between blank rows
    By foxxkat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2005, 05:53 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