Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pivot macros error 1004


dear all experts,

I had a macros to import all txt files from one folder and put the
into different worksheets but under one workbook. Then, i plan to us
pivot to do some processing on each worksheet.First , i tried to us
"macro record " to capture the scripts but i would have this erro
"1004, unable to get pivot tables property of the worksheet class" whe
i run the script .Can somebody point out where is problem ?



Sub ABS()
Dim varr As Variant
Dim wkbk1 As Workbook
Dim wkbk As Workbook
Dim i As Long
Dim sh1 As Worksheet
Dim sName As String

varr = Array( _
"DATA1.log", _
"DATA2.log")

Set wkbk = ActiveWorkbook
For i = LBound(varr) To UBound(varr)
Workbooks.OpenText Filename:="C:\RAWDATA\2006\" & varr(i), _
Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False
Comma:=True, _
Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1)
Array(2, 1), Array(3 _
, 1), Array(4, 1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit


Set wkbk1 = ActiveWorkbook
Set sh1 = wkbk.Worksheets.Add(after:= _
wkbk.Worksheets(wkbk.Worksheets.Count))
wkbk1.Worksheets(1).UsedRange.Copy _
Destination:=sh1.Range("A1")
sName = wkbk1.Name
sName = Left(sName, Len(sName) - 4)
wkbk1.Close SaveChanges:=False
sh1.Name = sName
Cells.Select
Cells.EntireColumn.AutoFit

Next


End Sub





Sub Macro1()
'
' Macro1 Macro

'

'
Range("H1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:
_
"DATA1!C1:C2").CreatePivotTable TableDestination:= _
"[test_pivot.xls]DATA1!R1C8", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("MO")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataFiel
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Attribute"), "Count of Attribute"
xlCount
Sheets("DATA2").Select
Range("H1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:
_
"DATA2!C1:C2").CreatePivotTable TableDestination:= _
"[test_pivot.xls]DATA2!R1C8", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("MO")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataFiel
ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Attribute"), "Count of Attribute"
xlCount
End Su

--
ymeya
-----------------------------------------------------------------------
ymeyaw's Profile: http://www.excelforum.com/member.php...fo&userid=3442
View this thread: http://www.excelforum.com/showthread.php?threadid=55593

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
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Pivot Table Run Time Error 1004 Dale Excel Programming 0 May 3rd 06 04:46 PM
pivot table Commandtext causes runtime error 1004 in excel 2000 Therezee Excel Programming 0 April 12th 06 04:39 AM
Pivot Table Error 1004 Terri[_5_] Excel Programming 1 May 26th 05 10:39 AM


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