51DegreesNorth
New Member
- Joined
- Mar 29, 2022
- Messages
- 11
- Office Version
- 365
- Platform
- Windows
This piece of code has a problem:
I want LocVar to have the correct value. My code stubbornly refuses to change LocVar to the specified value.
Is it right that the If_Then statement only accepts one line of code and if so, is there a workaround ?
Thank you !
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Loc_Var As String
LocVar = "AFR"
'First step: select location
If Not Intersect(Target, Range("F9")) Is Nothing Then
Range("A" & Sheets("VBA Data").Range("O35")).Select
LocVar = "XFD"
End If
If Not Intersect(Target, Range("F10")) Is Nothing Then
Range("A" & Sheets("VBA Data").Range("O36")).Select
LocVar = "BVC"
End If
If Not Intersect(Target, Range("F11")) Is Nothing Then
Range("A" & Sheets("VBA Data").Range("O37")).Select
LocVar = "SDF"
End If
End Sub
I want LocVar to have the correct value. My code stubbornly refuses to change LocVar to the specified value.
Is it right that the If_Then statement only accepts one line of code and if so, is there a workaround ?
Thank you !