Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Consolidate - Relative Reference

Hi all,

A while ago I asked about making a Macro portable (i.e. relative
references) - someone kindly responded but at the time it was beyond me to
implement. I have learned since then and have now managed to implement -
basically, open, manipulate, close and save workbooks is working fine.
However, in my 'summary' workbook I consolidate data from 4 other workbooks
and I'm struggling to edit the code to make this portable. My current code
follows and although it doesn't produce any errors, it does not consolidate
the data (if I quote the full path it works fine). The summary workbook is
always in the parent directory above Q1, Q2, Q3 and Q4:

Range("A7").Select
Selection.Consolidate Sources:=Array( _
ActiveWorkbook.Path & "'\Q1\[SummaryQ1.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q2\[SummaryQ2.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q3\[SummaryQ3.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q4\[SummaryQ4.xls]01'!R7C1:R205C20"), _
Function:=xlSum, TopRow:=False, LeftColumn:=True, CreateLinks:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2

Am I making a basic mistake or is it not quite as simple as I'm trying to
make it?

Many thanks.

Paul.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Consolidate - Relative Reference

You have your first single quote in the wrong place

ActiveWorkbook.Path & "'\Q1\[SummaryQ1.xls]01'!R7C1:R205C20",

should be

"'" & ActiveWorkbook.Path & "\Q1\[SummaryQ1.xls]01'!R7C1:R205C20",

otherwise it appears in the middle of your path.

--
Regards,
Tom Ogilvy

"Skip" wrote in message
...
Hi all,

A while ago I asked about making a Macro portable (i.e. relative
references) - someone kindly responded but at the time it was beyond me to
implement. I have learned since then and have now managed to implement -
basically, open, manipulate, close and save workbooks is working fine.
However, in my 'summary' workbook I consolidate data from 4 other

workbooks
and I'm struggling to edit the code to make this portable. My current code
follows and although it doesn't produce any errors, it does not

consolidate
the data (if I quote the full path it works fine). The summary workbook is
always in the parent directory above Q1, Q2, Q3 and Q4:

Range("A7").Select
Selection.Consolidate Sources:=Array( _
ActiveWorkbook.Path & "'\Q1\[SummaryQ1.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q2\[SummaryQ2.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q3\[SummaryQ3.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q4\[SummaryQ4.xls]01'!R7C1:R205C20"), _
Function:=xlSum, TopRow:=False, LeftColumn:=True,

CreateLinks:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2

Am I making a basic mistake or is it not quite as simple as I'm trying to
make it?

Many thanks.

Paul.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Consolidate - Relative Reference

Many thanks Tom,

Now works as I'd hoped.

Paul.

"Tom Ogilvy" wrote in message
...
You have your first single quote in the wrong place

ActiveWorkbook.Path & "'\Q1\[SummaryQ1.xls]01'!R7C1:R205C20",

should be

"'" & ActiveWorkbook.Path & "\Q1\[SummaryQ1.xls]01'!R7C1:R205C20",

otherwise it appears in the middle of your path.

--
Regards,
Tom Ogilvy

"Skip" wrote in message
...
Hi all,

A while ago I asked about making a Macro portable (i.e. relative
references) - someone kindly responded but at the time it was beyond me

to
implement. I have learned since then and have now managed to implement -
basically, open, manipulate, close and save workbooks is working fine.
However, in my 'summary' workbook I consolidate data from 4 other

workbooks
and I'm struggling to edit the code to make this portable. My current

code
follows and although it doesn't produce any errors, it does not

consolidate
the data (if I quote the full path it works fine). The summary workbook

is
always in the parent directory above Q1, Q2, Q3 and Q4:

Range("A7").Select
Selection.Consolidate Sources:=Array( _
ActiveWorkbook.Path & "'\Q1\[SummaryQ1.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q2\[SummaryQ2.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q3\[SummaryQ3.xls]01'!R7C1:R205C20", _
ActiveWorkbook.Path & "'\Q4\[SummaryQ4.xls]01'!R7C1:R205C20"), _
Function:=xlSum, TopRow:=False, LeftColumn:=True,

CreateLinks:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2

Am I making a basic mistake or is it not quite as simple as I'm trying

to
make it?

Many thanks.

Paul.






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
Relative Reference help Barnej75 Excel Discussion (Misc queries) 4 July 3rd 07 02:21 AM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
relative reference Swannybuck Excel Discussion (Misc queries) 1 July 26th 06 09:28 PM
relative reference nix2004 Excel Programming 3 April 20th 04 07:18 PM
relative reference Duce Excel Programming 1 October 24th 03 09:44 PM


All times are GMT +1. The time now is 04:57 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"