+ Reply to Thread
Results 1 to 20 of 20

Find Last Row Stop Macro if Cells are blank

  1. #1
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Find Last Row Stop Macro if Cells are blank

    I'm trying to develop a macro that will find the last row in column A (starting at row 7) check to see if there is content in both column A & B and if there isn't stop the macro. Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Find Last Row Stop Macro if Cells are blank

    Please Login or Register  to view this content.
    will return the last row number with a value in it in column A.

    Please Login or Register  to view this content.
    will stop the macro.

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    Is this what you are after?

    Test in atached file - runs with {CTRL} K
    Message box added to help you see when macro exits

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  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: Find Last Row Stop Macro if Cells are blank

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Thanks to all for responding to my quest. I had thought it would be easy once I had this but it appears not to be the case.

    Once I confirm the last cells in column A and B are not blank I wanted to call the followwing code.

    Please Login or Register  to view this content.
    But although it works with the code Kev has provided ( I changed the letters for numbers) it only checks it the once and then continues to add to the next row. Any suggestions?

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    What exactly are you trying to achieve?
    Explain the whole thing

    When should the macro continue checking?
    When should it stop?
    etc
    Perhaps attach a workbook with before and after sheets
    (Click reply, Go Advanced, look below for "Manage Attachments" etc to attach a workbook)

  7. #7
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Kev, again thanks for coming back. In answer to your question; I have a form which I manually populate and then using a macro it copies the data across to a table. At the starrt of the macro I want to check to see if I've inadvertently added an ID number without its detail which is what your macro does. However it provided a msgbox so when I replaced the box with the code above it doesn't work as intended and I just keep adding ID numbers. I hope this answers the question. Thanks

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    Yes - my code will find the first incidence where both columnA and columnB are blank
    - your code then adds 1 to the last found value in columnA

    When you say "it doesn't work as intended" what exactly do you want to happen after VBA finds the 2 columns blank?

  9. #9
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Kev, I have made changes to the macro you've provided and attached the file to show you what I hope to achieve. However, I not so sure the attachement has attached itself....but I'll find out in a minute
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    Is this what you want?
    - test in attached workbook

    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Kev, I'm sorry as I feel I'm imposing upon you now. The macro stills continues to add to Column A even though the last entry on column B is on row 10. I am expecting for the macro to add the value 4 to row 11 and if I run it again the macro stops. Thanks

  12. #12
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    Try this
    - I think you are trying to insert a value in column A if there is already something in columnB and keep going until columnA has caught up with columnB

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Kev, we have gone this far and I need to get my point across, which obviously I'm failing big time.

    The latest version of the macro appears ot do nothing.

    I have retunred the file to try and show what results are expected. I am truely grateful for your help
    Attached Files Attached Files

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

    Re: Find Last Row Stop Macro if Cells are blank

    Perhaps:

    Please Login or Register  to view this content.
    Could there be data missing in Column A and Column B would have data? Or will Column B always be the column with the data missing?
    Last edited by JOHN H. DAVIS; 09-07-2017 at 02:12 PM.

  15. #15
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    tomorrow...

  16. #16
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    John, the missing data will always be in column B. I will try the code in the morning and feed back. Thanks

  17. #17
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Find Last Row Stop Macro if Cells are blank

    test in the attached workbook with {CTRL} k
    - run in both sheet1 and sheet2

    Please Login or Register  to view this content.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    John, have tested the code but I'm afraid still doesn't work. Regards

  19. #19
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find Last Row Stop Macro if Cells are blank

    It can't be this simple.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  20. #20
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: Find Last Row Stop Macro if Cells are blank

    Mr B many thanks thats eacactly what I wanted - Thanks to all who contributed.

+ 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] VBA macro find blank RGB(0, 255, 0) colored cells in range and put in 1 value
    By KG869 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 02-09-2017, 11:07 AM
  2. I am in deperate need of a macro to find blank cells in a column and delete the row
    By leon1233 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2013, 05:57 PM
  3. Looking to create a macro that will skip blank cells in a column, find data cells
    By crayzwalz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 09:01 AM
  4. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  5. [SOLVED] How to ignore blank cells in a find macro
    By ANDREWA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2012, 01:34 PM
  6. Stop Macro if blank cells are within certain columns
    By superbob in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-07-2010, 08:45 AM
  7. [SOLVED] STOP BLANK CELLS
    By JFAZ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2006, 12:40 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