Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

select the datas up to the last coloumn and last row

  Asked By: Almas    Date: Mar 02    Category: MS Office    Views: 996
  

I made macro to make a pivot table.
The problem is: everytime I load the data that are some times the row
and the coloumn are not the same, sometimes more simetimes less. But the
field that I coose is always there
Question: how to create the command to select the datas up to the last
coloumn and last row?


Sub PM01_Pivot()
'
' PM01_Pivot Macro
' Macro recorded 2/14/2005 by wayan
'

'
ActiveWindow.SmallScroll ToRight:=-3
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=
_
"Sheet1!R1C1:R2374C12").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,
1)
ActiveSheet.Cells(3, 1).Select
With
ActiveSheet.PivotTables("PivotTable1").PivotFields("FunctLocation")
.Orientation = xlRowField
.Position = 1
End With
Range("A4").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("FunctLocation").
_
Orientation = xlHidden
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Main
WorkCtr")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("User
status")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Order"), "Count of Order", xlCount
End Sub

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Bryson Smith     Answered On: Mar 02

Try to record this macro

Edit >> Go To >> Special >> current region

The macro  would be like this
Sub Macro2()
'

Range("A1").Select
Selection.CurrentRegion.Select
End Sub

 
Didn't find what you were looking for? Find more on select the datas up to the last coloumn and last row Or get search suggestion and latest updates.




Tagged: