By syedsalman on Wednesday, 24 November 2021
Posted in Excel
Replies 3
Likes 0
Views 7.6K
Votes 0
Please correct the  2nd code, both for the same worksheet.

FIRST CODE WORKING PERFECTLY
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D1")) Is Nothing Then
Select Case Range("D1")
Case "0.5": Half
Case "1": One
Case "1.25": OneTwentyFive
End Select
End If
End Sub

SECOND CODE NOT WORKING (plz correct the below)
Private Sub Change(ByVal Target As Range)
If Not Intersect(Target, Range("D2")) Is Nothing Then
Select Case Range("D2")
Case "9.53": ninepointfivethree
End Select
End If
End Sub
Hi syedsalman,

For the same worksheet, you can the code:

Private Sub Worksheet_Change(ByVal Target As Range)


If Not Intersect(Target, Range("D1")) Is Nothing Then
Select Case Range("D1")
Case "0.5": Half
Case "1": One
Case "1.25": OneTwentyFive
End Select
End If

If Not Intersect(Target, Range("D2")) Is Nothing Then
Select Case Range("D2")
Case "9.53": ninepointfivethree
End Select
End If


End Sub


For different worksheets, you can just change "Private Sub Change(ByVal Target As Range)" in your second code to "Private Sub Worksheet_Change(ByVal Target As Range)".

Please try. Any questions please feel free to contact me.

Amanda
·
2 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Its working now with your correction

thank you so much for the help
·
2 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Its working now with your correction

thank you so much for the help

You are welcome.

Amanda
·
2 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post