Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Change hardcoded filename

Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Change hardcoded filename

Do you mean as the source or as the destination or both. I will assume both
as an example:

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")
set rng2 = ActiveWorkbooks.Worksheets("Labor").Range("C9").Cu rrentRegion

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=rng2.Address(1,1,xlR1C1,1), _
TableDestination:=rng1.Address(1,1,xlR1C1,1), _
TableName:="PivotTable1"

--
Regards,
Tom Ogilvy



"CLR" wrote:

Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Change hardcoded filename

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[" & Activeworkbook.Name & "]Pivots!R18C1", _
TableName:="PivotTable1"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"CLR" wrote in message
...
Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it

might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3




  #4   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Change hardcoded filename

Thanks Tom, but I'm getting an error message "Run Time Error 424 Object
Required" stoping on the line....

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")

What might I be doing wrong?

Vaya con Dios,
Chuck, CABGx3

"Tom Ogilvy" wrote:

Do you mean as the source or as the destination or both. I will assume both
as an example:

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")
set rng2 = ActiveWorkbooks.Worksheets("Labor").Range("C9").Cu rrentRegion

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=rng2.Address(1,1,xlR1C1,1), _
TableDestination:=rng1.Address(1,1,xlR1C1,1), _
TableName:="PivotTable1"

--
Regards,
Tom Ogilvy



"CLR" wrote:

Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Change hardcoded filename

Activeworkbooks is a typo and should be activeworkbook.

--
Regards,
Tom Ogilvy


"CLR" wrote:

Thanks Tom, but I'm getting an error message "Run Time Error 424 Object
Required" stoping on the line....

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")

What might I be doing wrong?

Vaya con Dios,
Chuck, CABGx3

"Tom Ogilvy" wrote:

Do you mean as the source or as the destination or both. I will assume both
as an example:

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")
set rng2 = ActiveWorkbooks.Worksheets("Labor").Range("C9").Cu rrentRegion

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=rng2.Address(1,1,xlR1C1,1), _
TableDestination:=rng1.Address(1,1,xlR1C1,1), _
TableName:="PivotTable1"

--
Regards,
Tom Ogilvy



"CLR" wrote:

Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3




  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Change hardcoded filename

That did the trick!!!
Thanks muchly kind Sir

Vaya con Dios,
Chuck, CABGx3



"Tom Ogilvy" wrote:

Activeworkbooks is a typo and should be activeworkbook.

--
Regards,
Tom Ogilvy


"CLR" wrote:

Thanks Tom, but I'm getting an error message "Run Time Error 424 Object
Required" stoping on the line....

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")

What might I be doing wrong?

Vaya con Dios,
Chuck, CABGx3

"Tom Ogilvy" wrote:

Do you mean as the source or as the destination or both. I will assume both
as an example:

set rng1 = Activeworkbooks.Worksheets("Pivots").Range("A18")
set rng2 = ActiveWorkbooks.Worksheets("Labor").Range("C9").Cu rrentRegion

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=rng2.Address(1,1,xlR1C1,1), _
TableDestination:=rng1.Address(1,1,xlR1C1,1), _
TableName:="PivotTable1"

--
Regards,
Tom Ogilvy



"CLR" wrote:

Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3


  #7   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Change hardcoded filename

This one worked just fine, once I got over the "word wrap" thing <g.

Thanks for the alternative, Bob.

Vaya con Dios,
Chuck, CABGx3



"Bob Phillips" wrote:

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[" & Activeworkbook.Name & "]Pivots!R18C1", _
TableName:="PivotTable1"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"CLR" wrote in message
...
Hi All........

I have the following code which works fine, but has the Filename hardcoded
therein, and whenever I change the filename, the macro quits working. How
might the code be changed to accomodate the Activefilename whatever it

might
be?

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Labor!R9C3:R173C22",
TableDestination:="[BigOneReport1j.xls]Pivots!R18C1", _
TableName:="PivotTable1"


TIA
Vaya con Dios,
Chuck, CABGx3





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
use Find without hardcoded value but a value from a cell Richhall[_2_] Excel Worksheet Functions 1 January 5th 10 05:07 PM
I need to change hardcoded background color Bridgette Culpepper Excel Worksheet Functions 2 October 25th 07 04:17 PM
VBA Code To find Hardcoded Values in Formula anjohn Excel Programming 4 August 19th 06 09:31 PM
change linked cells to black, hardcoded to blue Romanian37[_12_] Excel Programming 0 February 6th 06 10:21 AM
DSUM with Criteria containing non-hardcoded values? George Davis Excel Worksheet Functions 4 December 13th 05 08:11 PM


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