+ Reply to Thread
Results 1 to 2 of 2

Code to create atbs in excel sheet

  1. #1
    Registered User
    Join Date
    05-26-2006
    Posts
    2

    Question Code to create atbs in excel sheet

    My doubt is this.
    I need to write a program to open an excel sheet and copy 3 excel sheet into single .xls file which should contain 3 excel sheets.How do i proceed?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    To create your new workbook with three sheets you can use

    Sub Test()
    Workbooks.Add
    If ActiveWorkbook.Sheets.Count < 3 Then
    For N = 1 To 3 - ActiveWorkbook.Sheets.Count
    Sheets.Add
    Next N
    ElseIf ActiveWorkbook.Sheets.Count > 3 Then
    Application.DisplayAlerts = False
    For N = 1 To ActiveWorkbook.Sheets.Count - 3
    Sheets(1).Delete
    Next N
    Application.DisplayAlerts = True
    End If
    End Sub
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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