LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using variables to reference sheets


outputvar1 has been set previously through the use of radio buttons

this variable could be a different number everytime.

I then need to reference it later (see below in red)

Usually you would use the sheet name here, but as it changes I need to
reference the sheet from a variable.

Does that help??


Code:
--------------------
Set NewSheet1 = Worksheets.Add
NewSheet1.Name = outputvar1

Range("A10").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Control!$A:$X").CreatePivotTable TableDestination:= _
"'[Overheads.Engine.xls]*outputvar1*'!R10C1", TableName:="PivotTable1",
DefaultVersion:=xlPivotTableVersion10
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("CostCentre")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Account")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("GL Date")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Description")
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("RevisedBatch")
.Orientation = xlRowField
.Position = 4
End With
ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Certified Amount"), "Count of Certified Amount", _
xlCount
ActiveWorkbook.ShowPivotTableFieldList = False
Range("E16").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Count of Certified Amount") _
.Function = xlSum
Range("D11").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields ("RevisedBatch").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
Range("C11").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Description").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields ("CostCentre").CurrentPage = _
*outputvar1*
Range("B11").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields ("GL Date").Subtotals = Array _
(False, False, False, False, False, False, False, False, False, False, False, False)
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("GL Date")
.PivotItems("(blank)").Visible = False
End With
Range("A11").Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Account")
.LayoutBlankLine = True
.LayoutForm = xlOutline
End With
ActiveWindow.SmallScroll Down:=0

--------------------


--
marksince1984
------------------------------------------------------------------------
marksince1984's Profile: http://www.excelforum.com/member.php...o&userid=33484
View this thread: http://www.excelforum.com/showthread...hreadid=551223

 
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
Need to reference another sheet for two variables I M Desperate!!![_2_] Excel Worksheet Functions 1 June 14th 08 05:39 PM
Vary variables in a formula via reference to another cell Peter Excel Discussion (Misc queries) 2 July 21st 05 07:19 PM
reference variables correctly? Kieran1028[_2_] Excel Programming 1 October 27th 04 08:53 PM
reference variables correctly? Kieran1028[_3_] Excel Programming 0 October 27th 04 08:00 PM
Using variables to reference columns in VBA aktiv Excel Programming 3 May 24th 04 04:46 AM


All times are GMT +1. The time now is 03:21 AM.

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"