+ Reply to Thread
Results 1 to 1 of 1

Exporting data to VBA created workbook how can I send page data?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2007
    Location
    Florida
    MS-Off Ver
    Various
    Posts
    64

    Exporting data to VBA created workbook how can I send page data?

    Hello,

    I hobbled together a working macro through trial and error. I was wondering if someone could help me clean it up? I would like to learn how to do coding correctly and could use any advice you can give.
    Sub tester()
    Dim Newbook As Workbook
    Dim i As Integer
    Dim sName As String
    Dim umName As String
    Dim rvName As String
    Dim tBox As Integer
    
    
    
    line1:
    tBox = Application.InputBox(prompt:="Enter Number of Tasks", Type:=1)
    If tBox < 1 Then
    MsgBox "Must be at least 1"
    GoTo line1
    Else
    
    sName = ActiveSheet.Name
    umName = (sName & " Original")
    rvName = (sName & " Revised")
    
    Set Newbook = Workbooks.Add
        With Newbook
            .Title = sName
            .SaveAs Filename:=(sName & " .xls")
            .Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = umName
            .Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = rvName
            For i = 1 To tBox
            .Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = ("Task " & i)
            Next i
        End With
              
    End If
    End Sub
    And also, for this part:

    .Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = umName

    I would like to copy the contents of the current worksheet to this newly created worksheet on the new workbook.

    Can somone maybe help me work out how to do this?

    Any help appreciated.
    Last edited by Xaos; 08-26-2013 at 04:20 PM. Reason: Moderator Instructed title change

+ 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. [SOLVED] Cleaning up a Recorded Macro
    By 6423joel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2013, 09:58 AM
  2. Cleaning the files using macro
    By swathidas in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-05-2011, 01:56 PM
  3. Help cleaning up a macro
    By gugg7378 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-23-2011, 01:23 PM
  4. Sort Macro - Cleaning up code
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2010, 06:29 PM
  5. Cleaning up the code after recording a macro.
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-01-2010, 02:30 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