![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 47
|
I am looking to write a macro so that when a user inputs items in a cell and
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Helena, MT
Posts: 13,690
|
A change Event in the sheet code should do what you want. Something like
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$B$2" Then If Target.Value = 2 Then Sheets("Sheet2").Activate If Target.Value = 3 Then Sheets("Sheet3").Activate If Target.Value >= 4 Then Sheets("Sheet4").Activate End If End Sub Modify if needed |
|
|
|
|
|
#3 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Troy
Here is another way: Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lRow As Integer
Dim strName As String
If Target.Column <> 2 Then End
lRow = Target.Row
If lRow > 3 Then
Sheets("Sheet4").Select
Else
strName = Choose(lRow, "Sheet1", "Sheet2")
Sheets(strName).Select
End If
End Sub
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|