'VBA type Mismatch error,how can I be sure I'm defining the right value type to variables?
I'm trying to compare an String value and add a String result from that String Value, it throws an error type 13, I believe the error relies in the "Range" property,it works If I don't define an range and leave a single Cell value, but I need to check the same logic for a certain range.
Sub Vars()
'myVar = 20'
'MsgBox myVar'
Dim currencyVar As Double
Dim locationRange As String
Dim RangeResult As String
locationRange = Application.Sheets("Sheet4").Range("F3:F19")
RangeResult = Sheets("Sheet4").Range("G3:G19")
Debug.Print (locationRange)
mainXlookup = WorksheetFunction.XLookup(Sheets("Sheet4").Range("b3:b19"), Sheets("Sheet3").Range("b2:b18"), Sheets("Sheet3").Range("c2:c18"), "Not in project")
Sheets("Sheet4").Range("f3:f19") = mainXlookup
If locationRange = "Bethesda" Then
RangeResult = "In-Range"
End If
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
