Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    Santa Barbara CA
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Quickie Excel VBA (VBA 6.3/Excel 2002 SP2)

    I want a macro to see if there's a "B" in column P of the row I'm on. If so, nothing happens. If not, I get a dialog box that says "Oops!". Seems it should be easy, but it's been a while since I was in VBA; I feel silly asking such a simple question. Thanks for the help!

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quickie Excel VBA (VBA 6.3/Excel 2002 SP2)

    The code below should do that:

    <pre> If UCase(Range("P" & ActiveCell.Row).Value) <> "B" Then
    MsgBox "Column P does not contain a B."
    End If
    </pre>

    Legare Coleman

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Location
    Santa Barbara CA
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quickie Excel VBA (VBA 6.3/Excel 2002 SP2)

    Excellent, Legare. Thank you! I simply cut/pasted it into my code and it worked like a champ.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Quickie Excel VBA (VBA 6.3/Excel 2002 SP2)

    You asked (by PM) how to check if the active cell is in column K. Here is how to do that:

    If ActiveCell.Column <> 11 Then
    MsgBox "Active cell is not in column K."
    Exit Sub
    End If

    Since K is the 11th letter of the alphabet, the code tests whether the column number is 11. If you prefer to let Excel determine the column number, you can use

    If ActiveCell.Column <> Range("K1").Column Then

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Location
    Santa Barbara CA
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quickie Excel VBA (VBA 6.3/Excel 2002 SP2)

    Thanks to you, Hans (with earlier support from Legare) my little project can now be wrapped.

Posting Permissions

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