+ Reply to Thread
Results 1 to 19 of 19

Run Macro only if Column is Blank

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Run Macro only if Column is Blank

    Hi,

    I have data in Column P & Column Q. Unless I clear the data in that cell by removing manually, I do not want macro to proceed further.

    E.g.
    1) If there is a value in Cell P & Q, and if I run macro. I need a popup msg that "Complete the manual checking"
    2) If there is no value in Cell P & Q, then I only I should be allowed to execute my next macro which is

    Please Login or Register  to view this content.
    Please assist.

    Thanks
    Last edited by shiva_reshs; 09-19-2013 at 12:49 PM. Reason: Title Change
    Keep the Forum clean :


    1. Use [ code ] code tags [ /code ]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. Show appreciation to those who have helped you by clicking * Add Reputation below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  2. #2
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: VBA to run Macro 1 if Cell value is <> Blank, Run Macro2 if cell value is blank

    I was able create this code.

    Please Login or Register  to view this content.
    How can I modify this code so it can select more then P6. I mean Every cell of P and Q column?

    Regards

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: VBA to run Macro 1 if Cell value is <> Blank, Run Macro2 if cell value is blank

    I think I finally able to make perfect to match my requirement. But I am getting "Run Time error '424': Obeject required."

    Please Login or Register  to view this content.
    Please advice.

    Thanks

  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: VBA to run Macro 1 if Cell value is <> Blank, Run Macro2 if cell value is blank

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Thanks John,

    It works now.. But now I understood that, running this code would VBA to check 66500 cells and it would be a really long time.
    Is it possible for VBA to check column at once instead of each cell?

    If not, then can you help me with the code which starts from bottom. I just thought of an idea to do this from bottom up.

    Regards
    Thanks
    Last edited by shiva_reshs; 09-19-2013 at 02:19 PM.

  6. #6
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Hey John.

    Finally it is down. But John, how can can I make this loop till it reaches header of the column? Header name is "Stocks" and I want loop to stop there.

    Please Login or Register  to view this content.

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

    Re: Run Macro only if Column is Blank

    The current code goes to only the last used row of the spreadsheet. I assume it's not 66500. How many times do you want to Call Macro 12?

    This will do from the bottom up.

    Please Login or Register  to view this content.

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

    Re: Run Macro only if Column is Blank

    Quote Originally Posted by shiva_reshs View Post
    Hey John.

    Finally it is down. But John, how can can I make this loop till it reaches header of the column? Header name is "Stocks" and I want loop to stop there.

    Please Login or Register  to view this content.
    If your header is in row 1.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Hi,

    Tried your code. It even calls Macro 12 even when cell value is no equal to blank in P.



    Macro 12 below

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    wait. let me try your new code.

  11. #11
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    ok. It even calls, when cell value is not blank.
    Header is in Row 5.

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

    Re: Run Macro only if Column is Blank

    Can you attach a sample file?

  13. #13
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Right the cell is blank in this attachment.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    I found another code created by JasperD.

    Please Login or Register  to view this content.
    I am trying to convert code like if filter value is <> "" then msgbox "do the manual" or else run macro12.

    *Condition if it is possible

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run Macro only if Column is Blank

    What is the wrong with the code you have in post #3?

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Hi AB,

    It calls macro12, even when cell is not blank.

    E.g . If you look at the attached spreadsheet and add some Data in Column P & Q of last row, then code should give msg as "Do the manual" but instead it calls Macro12.

  17. #17
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run Macro only if Column is Blank

    You need to change AND to OR

  18. #18
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run Macro only if Column is Blank

    Try this one. It works on the attaché sheet

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: Run Macro only if Column is Blank

    Thanks!! It Worked...

+ 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] Cell referenced in formula has no information displayed (shows blank), return blank cell
    By nunayobinezz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2013, 04:51 PM
  2. If cell blank OR another cell blank then show blank, if not display value
    By stevop622 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-09-2013, 04:07 AM
  3. [SOLVED] 1 or blank cell pulls exact text or leaves cell blank
    By sharpmel in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-30-2012, 12:20 PM
  4. [SOLVED] If one cell contains #, & other cell is blank, show message & require blank be resolved
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-19-2012, 02:23 PM
  5. Macro that finds first blank cell or first blank row
    By SimonTheWee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2011, 11:04 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