+ Reply to Thread
Results 1 to 4 of 4

Copy range from 1 sheet to another workbook with VBA

  1. #1
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Lightbulb Copy range from 1 sheet to another workbook with VBA

    Hi
    I need a VBA Code to create a macro to get rid of tiresome work….
    I am using Office 2010.
    I have an folder name D:\Policy Data in which Policy Record.xlsx is File which contains 6 sheets.
    Out of these sheets, 1 sheet named "OUTPUT" has contain cell A1 : Branch Name & B1 : Today Date & I want to copy cell range from A2:AQ10456 to another workbook as values which must have name as Branch Name with date.xlsx because in this sheet I have used Array formulas to get desired on the basis of A1: Branch Name & B1: Today Date
    In manual practice I have to copy cell into another workbook as values & save it as ‘branch name with Date’ for all 37 branches everyday.
    Can anyone help me to get out of this annoying work??
    Thanks a lot in advance…

  2. #2
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Re: Copy range from 1 sheet to another workbook with VBA

    This code I have got from Chandoo.org to copy range cells to another workbook

    Sub copy2report()
    'Workbooks.Open "C:\Report.xls" 'change path as required
    Range("C5:M500").Copy 'define the range to copy
    'Windows("Report").Activate
    'Sheets("Data").Select
    Workbooks.Add
    Range("C1").PasteSpecial xlPasteAll
    Application.CutCopyMode = False
    ActiveWorkbook.SaveAs "C:\Report" & Format(Now(), "DD-MM-YYYY") 'change date format as required
    End Sub

    This code I have got from MrExcel Forum for selecting file name after copying data to another workbook

    Sub cpyNwb2()
    Dim sh As Worksheet, wb As String, newWb As Workbook
    wb = ThisWorkbook.FullName
    Set sh = ActivieSheet
    Set newWb = sh.Copy
    newWb.Sheets(1).Name = Range("A2").Value
    newWb.SaveAs Range("A1").Value
    Workbooks.Open wb
    newWb.Close
    End Sub


    Kindly look into this..... is it useful or how i can merge this to get desired results......
    I want values in new workbook which have name from define cell values.......

  3. #3
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Re: Copy range from 1 sheet to another workbook with VBA

    Default Re: Copy range from 1 sheet to another workbook with VBA

    I have used this code & it works perfect...
    I have made 1 change that instead of two cells I have merged it to 1 for giving name to new workbook....
    Any way thanks.........

    Sub GenerateNewFile()
    Dim wbI As Workbook, wbO As Workbook
    Dim wsI As Worksheet, wsO As Worksheet
    Dim nPath As String
    nPath = "D:\" & ThisWorkbook.Sheets("Output").Range("C1").Value & ".xlsx"
    Set wbI = ThisWorkbook
    Set wsI = wbI.Sheets("Output")

    Set wbO = Workbooks.Add

    With wbO

    Set wsO = wbO.Sheets("Sheet1")

    .SaveAs FileName:=nPath

    wsI.Range("A3:AE10300").Copy

    wsO.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    End With
    End Sub

  4. #4
    Forum Contributor
    Join Date
    12-03-2014
    Location
    India
    MS-Off Ver
    2016 .......
    Posts
    390

    Re: Copy range from 1 sheet to another workbook with VBA

    Can anyone provide help for finding accurate rows & columns to copy into new workbook in above code

    wsI.Range("A3:AE10300").Copy

+ 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. Copy Named Range to new sheet in workbook
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2014, 02:25 PM
  2. VBA newbie - copy range/rows from sheet into different workbook
    By luke1908 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2013, 06:20 AM
  3. copy a defined range from one workbook to the active sheet in another
    By DENWARD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2013, 07:49 AM
  4. Copy range of data from protected Sheet to another workbook
    By bang2013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2013, 03:30 PM
  5. Copy a range form one sheet to a new Workbook (for archive)
    By crycx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2013, 03:53 PM
  6. Macro, copy UNLOCKED cell range of sheet in open workbook to workbook template
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-31-2012, 11:18 AM
  7. [SOLVED] Search for heading in data sheet and copy range to corresponding sheet in master workbook
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 10:02 AM

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