Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Where is my syntax error?
Can anyone tell me what is wrong with my syntax below? I
have a variable called "lastrow" and I want to set myrange to be equal to C through Y of the last row. For instance, if the last row is 39, I would want myrange = range("C39:Y39"). My code follows: Set myrange = Worksheets("Practice").Range ("c"&lastrow&":y"&lastrow) Thanks, Mike. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Where is my syntax error?
I believe I've figured it out ... Apparently, you need to
type a space before and after the "&" symbol. My new statement is: Set myrange = Worksheets("Practice").Range("c" & lastRow & ":y" & 39) Mike. -----Original Message----- Can anyone tell me what is wrong with my syntax below? I have a variable called "lastrow" and I want to set myrange to be equal to C through Y of the last row. For instance, if the last row is 39, I would want myrange = range("C39:Y39"). My code follows: Set myrange = Worksheets("Practice").Range ("c"&lastrow&":y"&lastrow) Thanks, Mike. . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Where is my syntax error?
Mike,
You are correct. VBA uses the '&' character for several things, including concatenating string, declaring variable types, and declaring numeric bases. You need the spaces to let VBA know what you are actually doing. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Mike" wrote in message ... I believe I've figured it out ... Apparently, you need to type a space before and after the "&" symbol. My new statement is: Set myrange = Worksheets("Practice").Range("c" & lastRow & ":y" & 39) Mike. -----Original Message----- Can anyone tell me what is wrong with my syntax below? I have a variable called "lastrow" and I want to set myrange to be equal to C through Y of the last row. For instance, if the last row is 39, I would want myrange = range("C39:Y39"). My code follows: Set myrange = Worksheets("Practice").Range ("c"&lastrow&":y"&lastrow) Thanks, Mike. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Syntax Error In Date | Excel Discussion (Misc queries) | |||
Syntax error | Excel Discussion (Misc queries) | |||
syntax error - help | Excel Discussion (Misc queries) | |||
Vlookup Syntax Error | New Users to Excel | |||
need help with simple syntax error | Excel Programming |