Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Error In Date Beth Excel Discussion (Misc queries) 2 March 11th 09 01:05 PM
Syntax error Neil Pearce Excel Discussion (Misc queries) 4 November 21st 08 04:55 PM
syntax error - help Jim May Excel Discussion (Misc queries) 2 August 23rd 07 09:08 PM
Vlookup Syntax Error YV New Users to Excel 9 December 23rd 04 05:28 PM
need help with simple syntax error Gwill Excel Programming 1 July 15th 03 08:24 AM


All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"