Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

non contiguous range object 2

Status
Not open for further replies.

longestdrive

Programmer
Jan 23, 2007
26
GB
Hi all

I'm gradually getting through my project thanks to your help. I now have a working export from ms project to excel.

I had trouble setting the range object and should have specified the sheet object before the range. but that's ok now.

My problem now is setting range to equal two sets of cells within the sheet.

Here's the bare bones code:
Code:
Set xlRange = xlSheet.Range(xlSheet.Range(xlSheet.Cells(1, 3), xlSheet.Cells(1, TSV.Count)), xlSheet.Range(xlSheet.Cells(sumHrsRow, TSV.Count + 1), xlSheet.Cells(sumHrsRow, TSV.Count + 2)))

xlrange is a range object
xlsheet is a dim object
tsv.count is a column count

This code results in a complete block, rather than two distinct areas.

I'm struggling with getting to grips with range, offset, cells etc. How can I set the range object to non contigous areas?

Thank you

LD
 
I'd use the Excel.Application.Union method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



Hi,

Code:
dim rng as excel.range, xl as new excel.application

'assuming that range1 & range2 have been properly referenced
set rng = xl.union(range1, range2)

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top