Results 1 to 7 of 7

VBA: Custom Sheetname that keeps on counting

Threaded View

dutchyboy VBA: Custom Sheetname that... 05-05-2017, 09:20 AM
mehmetcik Re: VBA: Custom Sheetname... 05-05-2017, 06:46 PM
dutchyboy Re: VBA: Custom Sheetname... 05-08-2017, 02:57 AM
MarvinP Re: VBA: Custom Sheetname... 05-05-2017, 07:27 PM
Sintek Re: VBA: Custom Sheetname... 05-08-2017, 05:45 AM
dutchyboy Re: VBA: Custom Sheetname... 05-08-2017, 07:58 AM
Sintek Re: VBA: Custom Sheetname... 05-08-2017, 08:08 AM
  1. #1
    Registered User
    Join Date
    05-05-2017
    Location
    Utrecht, Netherlands
    MS-Off Ver
    2016
    Posts
    15

    VBA: Custom Sheetname that keeps on counting

    Hi all,

    I have a simple problem, but since I am nog an expert in VBA (yet), I hope someone here can provide me with the solution.

    I created a VBA code that creates a Pivot table at another sheet. With 'newsheet' I run the macro over and over again and everytime it creates a different sheet. Now I would like to have the same but then Excel should automatically add a number to a custom sheetname. So far I was only able that Excel gives the name once. How can I add something like 'count worksheets + 1', so that the new sheet changes in this example to sheetname_Pivot1, sheetname_Pivot2, sheetname_Pivot3 etc.

    Below you can find my code.

    TIA, KR!
    Paul

    ----
    Dim dataname As String
    Dim datasheetname As String
    Dim pivotsheetname As String
    
        dataname = ActiveSheet.ListObjects(1).Name
        datasheetname = ActiveSheet.Name
        pivotsheetname = datasheetname & "_Pivot"
        
        Sheets.Add
        ActiveSheet.Name = pivotsheetname
        
        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=dataname, Version:=xlPivotTableVersion15).CreatePivotTable _
            TableDestination:=pivotsheetname & "!R3C1", TableName:="PivotTable7", DefaultVersion:=xlPivotTableVersion15
        Sheets(pivotsheetname).Select
        Cells(3, 1).Select
    -----
    Last edited by dutchyboy; 05-08-2017 at 02:55 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Cell = sheetname get values from sheetname
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2014, 10:00 AM
  2. Adding into sheetname
    By BALA1983 in forum Excel General
    Replies: 1
    Last Post: 03-14-2014, 11:07 AM
  3. Using Sheetname in Vlookup as the sheetname for the array to lookup
    By OhioHsSport in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-05-2013, 09:18 PM
  4. [SOLVED] Custom counting functions not updating?
    By kortex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2012, 12:02 AM
  5. Excel 2007 : Custom grouping and counting
    By ALeece in forum Excel General
    Replies: 3
    Last Post: 05-13-2011, 12:20 PM
  6. If Sheetname is NOT Then.
    By ABBOV in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-03-2010, 02:27 PM
  7. Sheetname
    By monor in forum Excel General
    Replies: 1
    Last Post: 01-10-2006, 10:00 AM

Tags for this Thread

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