Thread: Macro question
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Macro question

some good answers. Here's something a little different.
Assume that you have a number of cells that you want to trap entered valued
for, and that these values may change.
on sheet1 select a range for input and name it InputCells
select another range and call this TestValues and put some numbers in here

add this code to the sheet's code page:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim found As Range
Set found = Intersect(Range("inputcells"), Target)
If Not found Is Nothing Then
Set found = Range("TestValues").Find(Target.Value)
If Not found Is Nothing Then
MsgBox "OK"
'worksheets("Sheet2").Activate
End If
End If
End Sub

This will fire OK if any value entered into any of the Input cells matches
any value in the testvalues table.

The following code assunes a range of inputcells as before, but each cell
to its left is the test value for any of the input cells...this then will
fire if the value enetered into an input cell matches th evalue in the cell
to its left

Private Sub Worksheet_Change(ByVal Target As Range)

Dim found As Range
Set found = Intersect(Range("inputcells"), Target)

If Not found Is Nothing Then
If found.Offset(0, -1).Value = Target.Value Then
MsgBox "OK"
'worksheets("Sheet2").Activate
End If
End If

End Sub

The objectiove here is to demonstrate possibilities

Patrick Molloy
Microsoft Excel MVP

"ew" wrote:

I need to build a macro that will take the user to another worksheet when a
specific value is entered into a cell. Any suggestions?
Thanks,
ew