Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Pivot Table variable range

I have 1 sheet where timesheet data is add.
a 2nd sheet contains a pivot table with dates of sheet1 (timesheet details)
grouped by qtrs and months.

As the time sheet entries are added I need to alter the pivot table range in
sheet 2 to suit as if there are any blank dates (even if not selected)then
grouping doesn't work (therefore can't just use R3C1:R35000C14) allowing for
future time sheet entries.

I want to creat a command button on sheet 1 so that after input of new
timesheet data on pressing the command button the last row of data is
indentified and then the pivot table range is adjusted and refreshed.

I have the code working to find the last row no. but keep getting an error
when trying to update the pivot table range. I show code below :-
Sub LastRowWithoutFormula()
Dim NoF, i, r As Integer

Range("A65536").End(xlUp).Select
NoF = Selection.Row
Range(NoF & ":" & NoF).Select

For i = 10 To 1 Step -1
For Each Cell In Selection
If Cell.HasFormula Then
NoF = NoF - 1
Range(NoF & ":" & NoF).Select
Else
Exit For
End If
Next
Next i

r = ActiveCell.Row
Cells(r, 14).Select

Sheets("Sheet1").Select
Range("C6").Select
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"'Time Sheet Information '!R3C1:R("r")C14" **** line which won't work
ActiveSheet.PivotTables("PivotTable2").PivotCache. Refresh
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Pivot Table variable range

You could use a dynamic source for the pivot table, and it will adjust
automatically as new rows are added. There are instructions he

http://www.contextures.com/xlPivot01.html

La Durande wrote:
I have 1 sheet where timesheet data is add.
a 2nd sheet contains a pivot table with dates of sheet1 (timesheet details)
grouped by qtrs and months.

As the time sheet entries are added I need to alter the pivot table range in
sheet 2 to suit as if there are any blank dates (even if not selected)then
grouping doesn't work (therefore can't just use R3C1:R35000C14) allowing for
future time sheet entries.

I want to creat a command button on sheet 1 so that after input of new
timesheet data on pressing the command button the last row of data is
indentified and then the pivot table range is adjusted and refreshed.

I have the code working to find the last row no. but keep getting an error
when trying to update the pivot table range. I show code below :-
Sub LastRowWithoutFormula()
Dim NoF, i, r As Integer

Range("A65536").End(xlUp).Select
NoF = Selection.Row
Range(NoF & ":" & NoF).Select

For i = 10 To 1 Step -1
For Each Cell In Selection
If Cell.HasFormula Then
NoF = NoF - 1
Range(NoF & ":" & NoF).Select
Else
Exit For
End If
Next
Next i

r = ActiveCell.Row
Cells(r, 14).Select

Sheets("Sheet1").Select
Range("C6").Select
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"'Time Sheet Information '!R3C1:R("r")C14" **** line which won't work
ActiveSheet.PivotTables("PivotTable2").PivotCache. Refresh
End Sub



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
Lookup Table - Variable Range Jim Bisset About this forum 0 February 10th 11 01:16 PM
Entering Variable in a Pivot Table flyer27 Excel Discussion (Misc queries) 0 March 13th 07 03:05 PM
Pivot table with a variable range in the sourcedata field [email protected] Excel Discussion (Misc queries) 2 January 31st 07 12:11 AM
Im so close. Need variable range for the pivot table Loren[_2_] Excel Programming 1 October 5th 04 10:53 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


All times are GMT +1. The time now is 09:52 AM.

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"