Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default syntax error

I'm trying to select several ranges at the same time with variable and am
getting an error message. I'm sure it is a syntax issue. Following is the
code in question. I'd appreciate any help with resolving this issue. Thanks
for the help.

Range(("A" & frow, "A" & lrow), ("C" & frow, "C" & lrow), ("E" & frow, "F" &
lrow), ("H" & frow, "I" & lrow)).select

frow is a variable I set for the first row of data and lrow is a variable I
set for the last row of data.

Thanks again for all of the help......
--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default syntax error

JT wrote:
I'm trying to select several ranges at the same time with variable and am
getting an error message. I'm sure it is a syntax issue. Following is the
code in question. I'd appreciate any help with resolving this issue. Thanks
for the help.

Range(("A" & frow, "A" & lrow), ("C" & frow, "C" & lrow), ("E" & frow, "F" &
lrow), ("H" & frow, "I" & lrow)).select

frow is a variable I set for the first row of data and lrow is a variable I
set for the last row of data.

Thanks again for all of the help......



":" not ,

"A" & frow & ":A" & lrow
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default syntax error

One way:

Dim fRow As Long
Dim lRow As Long

fRow = 5
lRow = 10

Range("A" & fRow & ":A" & lRow _
& ",C" & fRow & ":C" & lRow _
& ",E" & fRow & ":F" & lRow _
& ",H" & fRow & ":I" & lRow).Select

or something like (I like it better):

Union(Range(Cells(fRow, "A"), Cells(lRow, "A")), _
Range(Cells(fRow, "C"), Cells(lRow, "C")), _
Range(Cells(fRow, "E"), Cells(lRow, "F")), _
Range(Cells(fRow, "H"), Cells(lRow, "I"))).Select




JT wrote:

I'm trying to select several ranges at the same time with variable and am
getting an error message. I'm sure it is a syntax issue. Following is the
code in question. I'd appreciate any help with resolving this issue. Thanks
for the help.

Range(("A" & frow, "A" & lrow), ("C" & frow, "C" & lrow), ("E" & frow, "F" &
lrow), ("H" & frow, "I" & lrow)).select

frow is a variable I set for the first row of data and lrow is a variable I
set for the last row of data.

Thanks again for all of the help......
--
JT


--

Dave Peterson
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 loopoo[_13_] Excel Programming 3 November 22nd 05 12:53 PM
variable not declared error & syntax error G. Beard Excel Programming 1 October 6th 05 09:16 PM
Syntax Error help Markantesp Excel Programming 1 March 8th 05 09:51 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
Where is my syntax error? Mike Excel Programming 2 December 16th 03 10:43 PM


All times are GMT +1. The time now is 07:18 PM.

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

About Us

"It's about Microsoft Excel"