+ Reply to Thread
Results 1 to 6 of 6

copy data from one worksheet to new workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    03-07-2013
    Location
    zurich
    MS-Off Ver
    Excel 2010
    Posts
    99

    copy data from one worksheet to new workbook

    Hi.

    In attached sheet, I want to copy the data with country name as 'US' into new workbook and then rename with workbook with country name + sysdate (i.e. "US_20140219").
    Can anyone help me. Data are present in dynamic range in both rows and columns
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy data from one worksheet to new workbook

    Maybe:

    Sub abraham30()
    Dim ws As Worksheet
    Dim ws2 As Worksheet
    Set ws = ActiveSheet
    Workbooks.Add
    ActiveWorkbook.SaveAs "US_" & Format(DateAdd("yyyy", 0, Date), "yyyymmdd")
    Set ws2 = ActiveWorkbook.Sheets("Sheet1")
    ws2.Rows(1).Value = ws.Rows(1).Value
    ws.Activate
    Range("A1:A" & Range("A" & Rows.count).End(3)(1).Row).AutoFilter 1, "US"
    Range("A2:D" & Range("A" & Rows.count).End(3)(1).Row).SpecialCells(xlCellTypeVisible).Copy ws2.Range("A" & Rows.count).End(3)(2)
    ws.AutoFilterMode = False
    ws.Cells.AutoFilter
    End Sub

  3. #3
    Registered User
    Join Date
    03-07-2013
    Location
    zurich
    MS-Off Ver
    Excel 2010
    Posts
    99

    Re: copy data from one worksheet to new workbook

    Thanks for your help.
    As the column are in dynamic range, the macro will not able to copy the data for those columns into new workbook.

    Can you plz check once again.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy data from one worksheet to new workbook

    Would the entirerow be a solution?

    Sub abraham30()
    Dim ws As Worksheet
    Dim ws2 As Worksheet
    Set ws = ActiveSheet
    Workbooks.Add
    ActiveWorkbook.SaveAs "US_" & Format(DateAdd("yyyy", 0, Date), "yyyymmdd")
    Set ws2 = ActiveWorkbook.Sheets("Sheet1")
    ws2.Rows(1).Value = ws.Rows(1).Value
    ws.Activate
    Range("A1:A" & Range("A" & Rows.count).End(3)(1).Row).AutoFilter 1, "US"
    Range("A2:A" & Range("A" & Rows.count).End(3)(1).Row).SpecialCells(xlCellTypeVisible).EntireRow.Copy ws2.Range("A" & Rows.count).End(3)(2)
    ws.AutoFilterMode = False
    ws.Cells.AutoFilter
    End Sub

  5. #5
    Registered User
    Join Date
    03-07-2013
    Location
    zurich
    MS-Off Ver
    Excel 2010
    Posts
    99

    Re: copy data from one worksheet to new workbook

    Thanks John for ur help

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy data from one worksheet to new workbook

    You're welcome. Glad to help out. If you consider your problem resolved then please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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] Copy data from one worksheet to another worksheet and or another workbook
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2012, 08:13 AM
  2. [SOLVED] copy data from worksheet to worksheet of same name in another workbook
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-25-2012, 12:42 PM
  3. Copy data from one worksheet into new tab of a different workbook
    By davidparkes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2011, 12:34 PM
  4. i need data to copy to next worksheet in workbook
    By hbasten in forum Excel General
    Replies: 3
    Last Post: 05-31-2009, 03:23 PM
  5. Replies: 1
    Last Post: 03-16-2006, 03:00 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