Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2012, 11:17 AM
ibrahimaa ibrahimaa is offline PivotTable Windows Vista PivotTable Office 2007
Advanced Beginner
PivotTable
 
Join Date: May 2011
Posts: 35
ibrahimaa is on a distinguished road
Default PivotTable


Are there codes that I can use in a macro to create a PivotTable? I mean to create the column and row labels and the value fields?

I appreciate your support. Thank you.
Reply With Quote
  #2  
Old 04-15-2012, 12:30 AM
ibrahimaa ibrahimaa is offline PivotTable Windows Vista PivotTable Office 2007
Advanced Beginner
PivotTable
 
Join Date: May 2011
Posts: 35
ibrahimaa is on a distinguished road
Default

I have find a way to resolve this issue. I have created a PivotTable as we usually do and I have recorded all the steps in a macro which I am using now in different places. Below is the code. Thank you.
Code:
Sub Macro3()
' Macro3 Macro
    Workbooks.Open Filename:= _
        "D:\TERMINATIONS.xlsx"
    Sheets("Terms").Select
    ActiveWindow.SmallScroll Down:=-12
    Range("H1:H18").Select
    ActiveWindow.ScrollRow = 3
    ActiveWindow.ScrollRow = 6
    ActiveWindow.ScrollRow = 10
    ActiveWindow.ScrollRow = 13
    ActiveWindow.ScrollRow = 18
    ActiveWindow.ScrollRow = 30
      Range("H1:H627").Select
    Sheets.Add
    ActiveWorkbook.PivotCaches.create(SourceType:=xlDatabase, SourceData:= _
        "Terms!R1C8:R627C8", Version:=xlPivotTableVersion14).CreatePivotTable _
        TableDestination:="Sheet1!R3C1", TableName:="PivotTable1", DefaultVersion _
        :=xlPivotTableVersion14
    Sheets("Sheet1").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Emp Subgrp Desc")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveWorkbook.save
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy Before:=Workbooks("1575Examples.xlsm").Sheets(4)
    ActiveWorkbook.save
    Windows("TERMINATIONS.xlsx").Activate
    ActiveWorkbook.ShowPivotTableFieldList = False
    ActiveWindow.Close
    Range("E17").Select
    ActiveWorkbook.save
End Sub
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 06:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft