MannStewart
New Member
- Joined
- Oct 5, 2019
- Messages
- 14
Hi
1) Can anyone guide me as where I am writing my code wrong? I need my worksheet to do two separate things for two sets of ranges via worksheet_Change event. the top part works, but the latter part doesn't run at all, ie. the part where I need Excel to locate & go to the adjacent cell by Searching in BG1:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("BD2:BD1000")) Is Nothing Or Target.Cells.Count > 1 Then
Exit Sub
Else
Range("BF2:BF1000").Calculate
End If
Dim KeyCells As Range
Set KeyCells = Range("BG1")
Dim FindString As String
Dim Rng As Range
FindString = Range("BG1").Value
If Trim(FindString) <> "" Then
With Range("BC2:BC1000")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
ActiveCell.Offset(0, 1).Select
Else
MsgBox "Not found / Check your entry length & format."
End If
ActiveSheet.Range("BG1").ClearContents
End With
End If
End Sub
2) I also need to write another Worksheet Change code for Excel to jump to the adjacent cell (OFFSET 0,1) whenever I hit ENTER for any cell within the range D2:K1000, but I don't know know to proceed with the above section 2 stuck.
Anyone can Help ..?
Stewart
1) Can anyone guide me as where I am writing my code wrong? I need my worksheet to do two separate things for two sets of ranges via worksheet_Change event. the top part works, but the latter part doesn't run at all, ie. the part where I need Excel to locate & go to the adjacent cell by Searching in BG1:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("BD2:BD1000")) Is Nothing Or Target.Cells.Count > 1 Then
Exit Sub
Else
Range("BF2:BF1000").Calculate
End If
Dim KeyCells As Range
Set KeyCells = Range("BG1")
Dim FindString As String
Dim Rng As Range
FindString = Range("BG1").Value
If Trim(FindString) <> "" Then
With Range("BC2:BC1000")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
ActiveCell.Offset(0, 1).Select
Else
MsgBox "Not found / Check your entry length & format."
End If
ActiveSheet.Range("BG1").ClearContents
End With
End If
End Sub
2) I also need to write another Worksheet Change code for Excel to jump to the adjacent cell (OFFSET 0,1) whenever I hit ENTER for any cell within the range D2:K1000, but I don't know know to proceed with the above section 2 stuck.
Anyone can Help ..?
Stewart