+ Reply to Thread
Results 1 to 14 of 14

want to check for empty cell with vba

  1. #1
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    want to check for empty cell with vba

    Please Login or Register  to view this content.
    I want to loop through cells of worksheet tab name "fruit" column F starting at row 6 to the last row of data
    checking if there are any empty cells. The code is not working though.

    Please offer suggestion

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: want to check for empty cell with vba

    Please Login or Register  to view this content.
    not sure you require arrays to do what your doing
    making it more complicated than it needs to be
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Quote Originally Posted by humdingaling View Post
    Please Login or Register  to view this content.
    not sure you require arrays to do what your doing
    making it more complicated than it needs to be
    Thank you that worked. How would I do this for 3 tabs that I would like to check please?

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: want to check for empty cell with vba

    Please Login or Register  to view this content.
    this will go thru all the tabs in your workbook
    if you want to skip a tab then add an extra IF statement at the start of the loop to skip it

    otherwise you can use IF statement to indicate specific which ws.name you want to run

  5. #5
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    many thanks that worked superbly

  6. #6
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Please Login or Register  to view this content.
    could you explain this line please?

    if you want to skip a tab then add an extra IF statement at the start of the loop to skip it
    please explain what the line of code would be:

    if ws.name = "fred" then ...

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: want to check for empty cell with vba

    Please Login or Register  to view this content.
    i put this in because in my testing i found that if there is nothing in column F
    this is the address that will come thru

    so i want to skip a whole section of the for each ws in worksheets Loop
    it goes straight to None:

    Please Login or Register  to view this content.
    if this is not what you want to happen...then i suggest you re-route it to something else

    Please Login or Register  to view this content.
    if tab is either bob fred or jim then it will skip

  8. #8
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Quote Originally Posted by humdingaling View Post
    Please Login or Register  to view this content.
    i put this in because in my testing i found that if there is nothing in column F
    this is the address that will come thru

    so i want to skip a whole section of the for each ws in worksheets Loop
    it goes straight to None:

    Please Login or Register  to view this content.
    if this is not what you want to happen...then i suggest you re-route it to something else

    Please Login or Register  to view this content.
    if tab is either bob fred or jim then it will skip
    many thanks that worked great

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: want to check for empty cell with vba

    attached the working file i was using to test
    added some extra comments
    hope it helps
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Thanks

    I tried modifying the code to account for the range starting at different columns on different worksheets but it yields incorrect result saying empty cell at F6 in tab "jam" (which is true) although i tried setting it to check from range H7?


    Please Login or Register  to view this content.
    sorry I fixed it I saw problem was the <> I changed to =.

  11. #11
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Quote Originally Posted by humdingaling View Post
    attached the working file i was using to test
    added some extra comments
    hope it helps
    Many Thanks

  12. #12
    Registered User
    Join Date
    08-26-2016
    Location
    Hong Kong
    MS-Off Ver
    2007
    Posts
    6

    Re: want to check for empty cell with vba

    Hi!

    I am new to VBA. If the cell are empty, I want a message pop up and ask user to fill before proceed and the excel should not be able to save if not filled. I searched the forum and found a post related to it and have code. But when I run it, I keep getting error message invalid outside procedure. If I want to run the same marco from C50-55, can I set code for once or have to do it 5 times ( meaning go into each cell’s code and paste the same code)
    Thank you.

    If IsEmpty(Range("c50")) Then
    Select Case MsgBox("c50 is empty. Do you want to continue?", vbYesNo Or _
    vbQuestion Or vbDefaultButton1, "Select option")

    Case vbYes
    'This must be filled
    Case vbNo
    Exit Sub
    End Select
    End If

  13. #13
    Registered User
    Join Date
    08-16-2016
    Location
    singapore
    MS-Off Ver
    2010
    Posts
    81

    Re: want to check for empty cell with vba

    Quote Originally Posted by nsue View Post
    Hi!

    I am new to VBA. If the cell are empty, I want a message pop up and ask user to fill before proceed and the excel should not be able to save if not filled. I searched the forum and found a post related to it and have code. But when I run it, I keep getting error message invalid outside procedure. If I want to run the same marco from C50-55, can I set code for once or have to do it 5 times ( meaning go into each cell’s code and paste the same code)
    Thank you.

    If IsEmpty(Range("c50")) Then
    Select Case MsgBox("c50 is empty. Do you want to continue?", vbYesNo Or _
    vbQuestion Or vbDefaultButton1, "Select option")

    Case vbYes
    'This must be filled
    Case vbNo
    Exit Sub
    End Select
    End If
    Sorry I am not expert so I do not know solution.
    It is better you start a new post with your problem stated there . Then the forum expert can help you.

  14. #14
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: want to check for empty cell with vba

    nsue

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ 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. check empty cell as per other cells in same row.
    By pranayttt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2013, 08:59 AM
  2. [SOLVED] How to check for an empty cell
    By Turtleman10 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-26-2012, 08:32 AM
  3. Empty Cell Check without Looping
    By TheMan4392000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2011, 11:53 PM
  4. Code to check if cell is empty
    By gshock in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2008, 03:45 PM
  5. check a cell is empty or not
    By associates in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-20-2006, 05:43 PM
  6. How do I check for an empty cell in a formula?
    By sasquatchbill in forum Excel General
    Replies: 4
    Last Post: 08-08-2006, 10:55 AM
  7. Check current cell is empty
    By bobocat in forum Excel General
    Replies: 3
    Last Post: 07-06-2006, 06:20 PM
  8. VB - Empty Cell Check
    By Fraggs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2005, 11:26 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