If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Question about Set = for split ranges.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-06, 04:17
daveo61 daveo61 is offline
Registered User
 
Join Date: Feb 2005
Location: England.
Posts: 232
Question about Set = for split ranges.

I'm having a problem trying to get Set = to allow a split range.

I'll explain. I have a custom function that allows you to get data from
another Workbook, one of the lines of code is this...

Set r = xlwb.Sheets(1).Range(Mid(xref, n + 1))

r is a Range variable. this is my problem variable.
xlwb is a Workbook variable that has already been set and is working fine.
xref is a string which contains (among other things) the range we want.
n is a variable which denotes where to find the range in xref. Again this is
fine.

I get a problem when I the Range(Mid(xref, n + 1)) evaluates to this...

Range(("A1:A10, C1:C10"))

I'm not sure if the syntax is wrong as I'm using the Set command or what.

Any help would be gratefully received.

TIA.
Reply With Quote
  #2 (permalink)  
Old 02-07-06, 23:57
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
daveo61,

You may have sorted this out by now. The syntax is wrong.

Instead of
"A1:A10, C1:C10"
maybe
"A1:A10", "C1:C10"

Though maybe not, too. The example I've given is equivalent to "A1:C10" and may not be what you want.

You may want
with xlwb.sheets(1)
Set r = Union(.Range("A1:A10"),.Range("C1:C10"))
end with

If so, you'll need to manipulate your text to achieve the result.

HTH,
Fazza
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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