+ Reply to Thread
Results 1 to 2 of 2

macro to run in diffferent workbooks

  1. #1
    Registered User
    Join Date
    01-02-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    95

    Exclamation macro to run in diffferent workbooks

    I have recorded a macro creating a pivot and doing the necessary pivot filters. I would like to be able to run this macro in different workbooks since I will be doing this a several excel files daily.

    As you can see in the code below the macro will only work on a specific worksheet.

    Thanks

    Sub accountlistingpivot()
    '
    ' accountlistingpivot Macro
    '

    '
    Windows("2015 09 17 - FE BPs and PTPs.xls").Activate
    Range("A1:Y11812").Select
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "F03_F04_F05!R1C1:R11812C25", Version:=xlPivotTableVersion10). _
    CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable12" _
    , DefaultVersion:=xlPivotTableVersion10
    Sheets("Sheet1").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable12").PivotFields("State_Code")
    .Orientation = xlColumnField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable12").PivotFields("Cycle")
    .Orientation = xlRowField
    .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable12").AddDataField ActiveSheet.PivotTables( _
    "PivotTable12").PivotFields("AccountNumber"), "Count of AccountNumber", xlCount
    ActiveSheet.PivotTables("PivotTable12").AddDataField ActiveSheet.PivotTables( _
    "PivotTable12").PivotFields("Billed_OB"), "Sum of Billed_OB", xlSum
    With ActiveSheet.PivotTables("PivotTable12").DataPivotField
    .Orientation = xlColumnField
    .Position = 2
    End With
    With ActiveSheet.PivotTables("PivotTable12").PivotFields("Sum of Billed_OB")
    .NumberFormat = "#,##0"
    End With
    Sheets("Sheet1").Select
    Sheets("Sheet1").Name = "Summary"
    End Sub

  2. #2
    Registered User
    Join Date
    01-02-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: macro to run in diffferent workbooks

    You can also see that it has a specific pivot number.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to Pull Data from Multiple Workbooks to One Master Workbooks
    By eranajoy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2019, 09:24 AM
  2. Macro to autoclose hidden workbooks is closing all active workbooks
    By tlchavez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2013, 06:38 PM
  3. [SOLVED] Macro to Saving Workbook Sheets as Separate Macro-Enabled Workbooks
    By puppetpalace in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2013, 01:58 PM
  4. Replies: 0
    Last Post: 08-07-2012, 02:19 PM
  5. [SOLVED] calculating data from diffferent worksheets
    By HNR in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 04-21-2012, 04:12 PM
  6. Applying macro within a custom macro button to all workbooks
    By clearwaterdave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2007, 12:16 PM
  7. Applying macro within a custom macro button to all workbooks
    By BigBas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-14-2007, 03:34 PM
  8. [SOLVED] AddName - issues w/ creating with reference to a diffferent workbook.
    By Mark J Kubicki in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2005, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1