Reputation: 21
I am trying to use a formula below and I keep on getting the expected end of statement error
Worksheets("Report").Cells(8,3).Value="='DATA'!B"&lRow-2&"*'DATA'!D"&lRow-2
The error occurs on "*'DATA'!D"
Expected: End of statement
Upvotes: 1
Views: 163
Reputation: 57683
When typing this line …
Worksheets("Report").Cells(8,3).Value="='DATA'!B"&lRow-2&"*'DATA'!D"&lRow-2
… into the editor make sure you have spaces in the correct places:
Worksheets("Report").Cells(8, 3).Value = "='DATA'!B" & lRow - 2 & "*'DATA'!D" & lRow - 2
Spacing is necessary because the &
has 3 different meanings:
Without space: Declare a number to be of type Long
:
2&
means that 2
is of type Long
.
(also see Declaring variables).
With spaces: Concatenate two strings:
&
with spaces means concatenate strings eg. TotalString = String1 & String2
(also see &-Operator)
&H
specifying a hexadecimal number:
Example &HF
means hexadecimal F
and Debug.Print &HF
will output 15 which is the hexadecimal F
converted into a decimal number.
Upvotes: 3
Reputation: 300
Worksheets("Report").Cells(8, 3).Value = "='DATA'!B" & lRow - 2 & "*'DATA'!D" & lRow - 2
Upvotes: 0