Results 1 to 4 of 4

Thread: Help:How to identify the sheet number of the first sheet?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    I have used this code to copy sheet with dynamics chart.

    Just test again. It works well. Dont know what wrong with old sheet.

    Let i try it and post later.

    thank for your prompt reply

    [vba]Sub CopySheetWithDynamicsChart()
    Dim nmeOrgSht As String
    Dim nmeDivSht As String
    Dim nmeOrgBook As String
    Dim nmeDivBook As String
    Dim numCopy As Integer
    Dim icount As Integer

    numCopy = InputBox("Insert Number of Copy", "test", 3)

    'get the current Workbook Name
    nmeOrgBook = ActiveWorkbook.Name
    'get the current WorkSheet Name
    nmeOrgSht = ActiveSheet.Name
    'Open new workbook
    Workbooks.Add
    'get newbook name
    nmeDivBook = ActiveWorkbook.Name
    'move the sheet intend to copy
    Workbooks(nmeOrgBook).Sheets(nmeOrgSht).Move Before:=Workbooks(nmeDivBook).Sheets(1)
    'get it name in new book
    nmeDivSht = ActiveSheet.Name
    'save and close new book as template file
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\temp.xls"
    nmeDivBook = "temp"
    ActiveWorkbook.Close False

    'Copy loop
    For icount = 1 To numCopy
    Workbooks.Open Filename:="C:\temp.xls"
    Sheets(nmeDivSht).Move Before:=Workbooks(nmeOrgBook).Sheets(1)
    Workbooks(nmeDivBook).Close False
    Next

    Kill ("C:\temp.xls")
    End Sub[/vba]
    Last edited by yurble_vn; 07-05-2007 at 09:01 AM.

Posting Permissions

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