Consulting

Results 1 to 5 of 5

Thread: Pull info from one Active Workbook and Save in Another

  1. #1
    VBAX Regular
    Joined
    Aug 2012
    Posts
    12
    Location

    Pull info from one Active Workbook and Save in Another

    Hi Guys,

    I am looking to macro that can pull information from a Active workbook and save/create it in another workbook.

    I have attached the file. I am looking to get A7:A20 and J6:J20

    So basically I would like to add a button on the Gas Analysis worksheet. click it and automatically creates a new excel with those 2 ranges.

    Thanks for your help!
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    [VBA]Sub a()
    Sheets(1).Range("A7:A20").Copy Sheets(2).Range("A7")
    Sheets(1).Range("J6:J20").Copy Sheets(2).Range("J6")
    Sheets(2).Copy

    End Sub[/VBA]

  3. #3
    VBAX Regular
    Joined
    Aug 2012
    Posts
    12
    Location
    Can i save it by the name of the sheets?

    Say if its Jun 2012, Jul 2012 ...are the sheet names and save it in a particular directory?

    Thanks so much

  4. #4
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Create activex button on sheet, then double click on it and drop this code in.
    [VBA]Private Sub CommandButton1_Click()
    Dim WBNew As Workbook
    Dim WS As Worksheet
    Set WS = ActiveSheet
    Set WBNew = Workbooks.Add

    WS.Range("A7:A20").Copy WBNew.Worksheets(1).Range("A7")
    WS.Range("J6:J20").Copy WBNew.Worksheets(1).Range("J6")

    End Sub[/VBA]

    David


  5. #5
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    [vba]Sub (a)
    filename=Sheets(1).name
    Sheets(1).Range("A7:A20").Copy Sheets(2).Range("A7")
    Sheets(1).Range("J6:J20").Copy Sheets(2).Range("J6")
    Sheets(2).Copy
    ActiveWorkbook.SaveAs Filename:=filename
    End Sub[/vba]

Posting Permissions

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