ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   syntax error (https://www.excelbanter.com/excel-programming/342191-syntax-error.html)

JT

syntax error
 
I'm trying to select several ranges using a variable (verylastrow) at the
same time to format the items in the selection but I am having a problem. It
must be Friday because I cannot figure out the syntax error in the following
code:

Range("(A1:A & verylastrow), D1:E & verylastrow), (G1:H &
verylastrow)").Select

I'm sure it is something simple but any help would be appreciated. Thanks.
--
JT

Tom Ogilvy

syntax error
 
Range("A1:A" & verylastrow & ",D1:E" & verylastrow _
& ",G1:H" & verylastrow).Select


from the immediate window:

verylastrow = 10
Range("A1:A" & verylastrow & ",D1:E" & verylastrow _
& ",G1:H" & verylastrow).Select
? SELECTION.ADDRESS
$A$1:$A$10,$D$1:$E$10,$G$1:$H$10

--
Regards,
Tom Ogilvy


"JT" wrote in message
...
I'm trying to select several ranges using a variable (verylastrow) at the
same time to format the items in the selection but I am having a problem.

It
must be Friday because I cannot figure out the syntax error in the

following
code:

Range("(A1:A & verylastrow), D1:E & verylastrow), (G1:H &
verylastrow)").Select

I'm sure it is something simple but any help would be appreciated.

Thanks.
--
JT




JT

syntax error
 
Thank you very much. The macro now does exactly what I'm trying to do.
Thanks again and have a good weekend.
--
JT


"Tom Ogilvy" wrote:

Range("A1:A" & verylastrow & ",D1:E" & verylastrow _
& ",G1:H" & verylastrow).Select


from the immediate window:

verylastrow = 10
Range("A1:A" & verylastrow & ",D1:E" & verylastrow _
& ",G1:H" & verylastrow).Select
? SELECTION.ADDRESS
$A$1:$A$10,$D$1:$E$10,$G$1:$H$10

--
Regards,
Tom Ogilvy


"JT" wrote in message
...
I'm trying to select several ranges using a variable (verylastrow) at the
same time to format the items in the selection but I am having a problem.

It
must be Friday because I cannot figure out the syntax error in the

following
code:

Range("(A1:A & verylastrow), D1:E & verylastrow), (G1:H &
verylastrow)").Select

I'm sure it is something simple but any help would be appreciated.

Thanks.
--
JT






All times are GMT +1. The time now is 08:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com