Results 1 to 3 of 3

Thread: Testing for cell values in Excel 97 ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    12

    Testing for cell values in Excel 97 ?

    I need to test the value in a cell that currently has validation turned on values displayed in a
    list (combo box)

    The routine in VBA is as follows:
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    WorkID = ActiveCell().Text
    If WorkID = "Flex" Then MsgBox "Please complete Flex-Time Form"
    End Sub

    My problem is that it only fires when I leave the cell and return back...How can I test the value in cell before, or as, I get to the next cell?

    This is Excel '97
    Thanks,

  2. #2
    Hyperactive Member Granty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    439
    workid = Me.Cells.SpecialCells(xlCellTypeLastCell).Text is how, but I have a feeling it will be tough. The message will fire as you leave the cell, but clicking the message box will fire the SelectionChange again and you'll be stuck in a loop.

  3. #3
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Just make sure you check the ActiveCell.Address to be the right cell...
    VB Code:
    1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    2.     If ActiveCell.Address = "$A$1" Then
    3.         'All your code here
    4.     End If
    5. End Sub
    That way it will only fire on the cell you want to check, I use it all the time to turn cells into buttons.

Posting Permissions

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



Click Here to Expand Forum to Full Width