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
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.
Worksheets("Report").Cells(8, 3).Value = "='DATA'!B" & lRow - 2 & "*'DATA'!D" & lRow - 2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.