+ Reply to Thread
Results 1 to 10 of 10

VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

  1. #1
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    IFVBA.xlsm

    I have a code here that finds a name in the database1 sheet and applies a payment, i have it matching the month as I want. Each Month is assigned 3 cells, for Pmt, Pmt Date, & Pmt Ref. What I need is to modify my code to check if any of the 3 cells are already populated and if so give a warning msgbox before entering the new payment info. If the 3 cells are all empty then no warning msgbox is needed and the new payment info can be entered as it is currently doing. All help is greatly appreciated!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    This code will do what you want:

    Please Login or Register  to view this content.

    And should replace all this code:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,571

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Similar approach ...

    Please Login or Register  to view this content.

    Regards, TMS
    Last edited by TMS; 02-01-2016 at 08:12 PM. Reason: Edited as per Bernie Deitrick's correction in post #4 (needed to increment the offsets)
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor unit285's Avatar
    Join Date
    10-29-2015
    Location
    TN
    MS-Off Ver
    Office 365
    Posts
    358

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Quote Originally Posted by Bernie Deitrick View Post
    This code will do what you want:

    Please Login or Register  to view this content.

    And should replace all this code:

    Please Login or Register  to view this content.
    Your consolidated code really made me feel the bern. and it works great. Thanks so much! I obviously have much to learn when it comes to vba

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,571

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Is that a comment or a question?

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    It is a correction, in bold. You did not increment the column for the other two existing value checks.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,571

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Ah, thank you for that. The bold did not show up particularly well and I saw what I expected to see, not what you had tried to draw my attention to.

    Thanks again. I will edit the post so that it is correct for anyone who tries to use it.

    Regards, TMS

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    Sorry - I should have explained, too, with more than just bolding.

    And thanks for the Rep, too.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,571

    Re: VBA Code to Check if a Range of cells is Empty or Not and run code accordingly

    @Bernie: you're welcome.

+ 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 code to check if a range of cells have the same value
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-20-2015, 11:40 PM
  2. VBA code to find max value in unsorted range with empty cells between
    By tnkcoll in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2015, 05:22 PM
  3. Amend code to do nothing if cells in a range are empty
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2015, 07:38 AM
  4. [SOLVED] Check if cell is empty before running code
    By cajand in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2014, 03:01 PM
  5. Replies: 0
    Last Post: 03-20-2014, 11:51 AM
  6. [SOLVED] still have empty cell after run Delete empty cells code
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2012, 04:28 PM
  7. 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

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