Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Macro: If a1 is blank, run macro X, else do nothing

  1. #1
    Board Regular
    Join Date
    Sep 2010
    Location
    Melbourne
    Posts
    184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Macro: If a1 is blank, run macro X, else do nothing

    I am trying to get my macro to do this on open. Check if a1 is empty, if its empty run another macro (which is an input box to put something IN a1), but if A1 has something in it, DO NOTHING.

    I keep getting errors, saying I'm not formulating my if statements correctly.

    This is what I have:
    Code:
     
    Private Sub Workbook_Open()
    If Range("a1") = "" Then macrox
    else do nothing
    End If
    End Sub

  2. #2
    Board Regular pedie's Avatar
    Join Date
    Apr 2010
    Location
    INDIA
    Posts
    3,875
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Macro: If a1 is blank, run macro X, else do nothing

    try..

    Code:
     
    'Thisworkbook code
    Private Sub Workbook_Open()
    try1
    End Sub
    'standard module code
    sub try1
    If Range("a1").value = "" Then
    macrox ' your macro
    else 
    exit sub 'do nothing
    End If
    end sub
    Regards,
    Pedie
    MS OFFICE 2016/EXCEL 2016: Window7: 64BIT
    Visit YouTube.com/VBAa2z


  3. #3
    Board Regular
    Join Date
    Sep 2010
    Location
    Melbourne
    Posts
    184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Macro: If a1 is blank, run macro X, else do nothing

    Pedie you are a legend, and your dog is adorable.
    But why did it hate me the first time? I thought I did it right :'(

  4. #4
    Board Regular pedie's Avatar
    Join Date
    Apr 2010
    Location
    INDIA
    Posts
    3,875
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Macro: If a1 is blank, run macro X, else do nothing

    Quote Originally Posted by oliviar View Post
    Pedie you are a legend, and your dog is adorable.
    But why did it hate me the first time? I thought I did it right :'(
    Guys please help i dont fully understand what this sentence suppose to mean
    'm english learner
    I can put in the inputbox but not sure what you want the input value to be like and wat u want to do with the value inputed so...
    Regards,
    Pedie
    MS OFFICE 2016/EXCEL 2016: Window7: 64BIT
    Visit YouTube.com/VBAa2z


  5. #5
    Board Regular
    Join Date
    Sep 2010
    Location
    Melbourne
    Posts
    184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Macro: If a1 is blank, run macro X, else do nothing

    No problems. It worked great. I was just wondering why it didn't work.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •