Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Mpls, Minnesota, USA
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to test for column (Excel 97)

    I know I have seen it before, but cannot remember how to do it.
    I am creating a macro that manipulates data (copies to new location) and I want it to test (at the begining) if the active cell is in Column B.
    If it is not in column B, terminate macro or show message box warning. If it is in Column B, proceed. The Row does not matter.
    I am leaving for the day, but will check the forum tomorrow morning.
    Thanks in advance,
    Chuck
    Chuck Reimer
    I'm from the Government and I'm here to help...

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to test for column (Excel 97)

    If ActiveCell.Column <> 2 Then
    Msgbox "Wrong Column"
    Exit Sub
    End If
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to test for column (Excel 97)

    John beat me to it....

    Try the following code:

    Sub TestColumn()
    If ActiveCell.Column = 2 Then
    'You're code here
    Else
    MsgBox "Not Column B"
    End If
    End Sub

  4. #4
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Paragould, Arkansas, USA
    Posts
    194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to test for column (Excel 97)

    Good morning!

    Rembmer Activecell attributes?

    Sub GetCol()
    If ActiveCell.Column = 2 Then
    MsgBox ("You are in column B!")
    End If
    End Sub

    Are you copying from Col. B, or are you pasting to Col B.? Or something else all together?
    Errol

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Mpls, Minnesota, USA
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks to
    JohnBF, jstevens and Errolv

    I have seen this many times and just could not remember! Thank you all very much.
    The user needs the data in column B on sheet1 copied to column B on second sheet (with some other manipulation).
    The source has the twelve months in cols B thru M (rows are the days of the month). He wants the data listed with the date in column A and the associated value in column B.
    I just wanted to do some testing before the macro processed - it has to start in column A and the cell has to contain a value (not blank or text).
    I am setting it to process a year at a time (there are many years of data going down the source sheet).
    Thanks again for the EXPERT help,
    Chuck
    Chuck Reimer
    I'm from the Government and I'm here to help...

Posting Permissions

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