+ Reply to Thread
Results 1 to 6 of 6

VBA Code to check cell before running macro

  1. #1
    Registered User
    Join Date
    02-15-2010
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    31

    Exclamation VBA Code to check cell before running macro

    Hello guys
    I need a vba code to check if some cells contain data (they must contain) before running a macro.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Code to check cell before running macro

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-15-2010
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: VBA Code to check cell before running macro

    Ok but I need to check to different cells like B3 and B5... What should I write?

  4. #4
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Re: VBA Code to check cell before running macro

    This code would check in the used range of the active sheet:

    Please Login or Register  to view this content.

    Regards,
    Karan

  5. #5
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: VBA Code to check cell before running macro

    This will easily allow you to add multiple cells

    Please Login or Register  to view this content.


    click on the * Add Reputation if this was useful or entertaining.

  6. #6
    Registered User
    Join Date
    02-15-2010
    Location
    Greece
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: VBA Code to check cell before running macro

    Thank you all for your advices. However the following worked for me:

    If IsEmpty(Range("B3").Value) Or IsEmpty(Range("B4").Value) Then
    .......
    Else
    ........

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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