+ Reply to Thread
Results 1 to 4 of 4

Do While IsEmpty Help

  1. #1
    Registered User
    Join Date
    04-02-2019
    Location
    US
    MS-Off Ver
    MS365 (PC) Version 2407
    Posts
    7

    Do While IsEmpty Help

    Hello, I just started learning VBA. I'm trying to write additional code that will check if a cell is empty within a specific column of a list/table, and if it is, it will go down a row until it hits a cell that isn't empty. Then it will go 1 cell to the left and add the comment "Pass", and finally go to the next cell that was originally checked if it was empty or not. I want this entire process to keep looping, something like the below code but it doesn't work-

    Please Login or Register  to view this content.
    That 2nd loop I'd want to return to the beginning of the first Do While, but it's not working. I think a Go To could be added for the beginning of the Do While, but I'd prefer not to use that because the lines could need updating. I'm interested in learning a better way to solve this issue so I can learn more. Another benefit is if someone ever needs to update my macro, they wouldn't have to worry about my Go To code.

    Does anyone have some advice as to how I can approach this?

    Thanks!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,743

    Re: Do While IsEmpty Help

    First, you need to have a way to know when you have reached the end of the column. Second, do not use Select and ActiveCell to navigate if you don't actually have to select the cell. Third, never use a GoTo.

    Can you explain a little more clearly in English (instead of describing your algorithm) what you want to do? Are you trying to simply put the word Pass to the left of every non-empty cell in a column, starting with the active cell? If so you want code like this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-02-2019
    Location
    US
    MS-Off Ver
    MS365 (PC) Version 2407
    Posts
    7

    Re: Do While IsEmpty Help

    Thank you for your valuable input! Since I'm still learning, I'm not aware of an easier way to code it so that it would know I've reached the last cell I would want it to loop through. I've tried attaching an example workbook of what my actual workbook looks like - I hope that helps visualize!

    Column C is the result of a match function. Column B are notes provided that I need to overwrite with the word "Pass" if the cells in Column C are not blank. Column A always has data filled in for every cell within my list.

    I've attempted using your proposed code to see how it works, but the line "LastRow = Cells(Rows.Count, ActiveCell.Columnn).End(xlUp).Row" gives me an excel prompt "Run-time error '438': Object doesn't support this property or method"

    I have an idea of what that code is trying to do and it seems like it's a step in the right direction for me, I'm just not 100% sure of everything it's doing. I don't think I'll have much more time tonight to look into it but tomorrow I can research what it's doing.
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,743

    Re: Do While IsEmpty Help

    Sorry, I didn't test it. There is an extra n at the end of Column. Here is a fix with an explanation.

    It looks like your code above starts with whatever the current active cell is, but from your later explanation it sounds like you want to check every cell in column C.

    Your sample file doesn't match your explanation. There are lots of values in column C that don't have a Pass in column B. But if you want a Pass for every nonblank in column C, then do this. Based on your explanation, you will always be checking all rows, and always column C. So I have made a couple of tweaks.

    Please Login or Register  to view this content.

+ 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. Isempty with If function in VBA
    By theprincesunil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2016, 02:00 PM
  2. Not isempty()
    By nikko50 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2013, 01:19 PM
  3. Using ISNA and ISEMPTY together
    By briggsy1300 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-30-2013, 07:50 AM
  4. Isempty problems
    By ajc5382 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2012, 11:03 PM
  5. Isempty with cells
    By katto01 in forum Excel General
    Replies: 2
    Last Post: 02-08-2012, 03:03 AM
  6. Do Until Cell IsEmpty
    By fa888 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2010, 11:29 PM
  7. IsEmpty
    By Determined in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2007, 07:44 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