+ Reply to Thread
Results 1 to 5 of 5

copying to a new workbook

Hybrid View

rjhe22 copying to a new workbook 01-03-2013, 05:25 AM
rjhe22 Re: copying to a new workbook 01-03-2013, 05:28 AM
Fotis1991 Re: copying to a new workbook 01-03-2013, 05:48 AM
rjhe22 Re: copying to a new workbook 01-07-2013, 11:01 AM
rjhe22 Re: copying to a new workbook 01-07-2013, 11:24 AM
  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    copying to a new workbook

    hi
    have this code which copies from 1 sheet to another
    how can i get it to copy from 1 excel file to another or is it possible
    here is my code
    Sub Exporting_Data1()
    Dim i As Long, LR As Long
    Application.ScreenUpdating = False
    On Error Resume Next
    
    Set ms = Sheets("Sheet2")
        With Worksheets("Sheet1")
            LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
              For i = 1 To LR
                 If IsDate(.Cells(i, 1)) Then
                     .Cells(i, 1).Copy
                    ms.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
                End If
                    If Len(.Cells(i, "AD")) And .Cells(i, "AD") = "FUND OWNERSHIP %" Then
                    .Cells(i, "AD").Offset(1).Resize(4).Copy
                    ms.Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
                  End If
              Next i
        End With
                    
    Application.CutCopyMode = 0
    Columns(1).NumberFormat = "dd/mm/yyyy"
    Application.ScreenUpdating = True
    
    
    
    End Sub

  2. #2
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: copying to a new workbook

    also is it possible if i have 4 sheets in 1 file to copy them over to 4 different sheets in the other file if so how can this be done

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: copying to a new workbook

    In a simple google searching, found these(and more more others)..

    http://www.excelforum.com/excel-form...-workbook.html

    http://www.ozgrid.com/forum/showthread.php?t=61202
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: copying to a new workbook

    ya but i dont get what i have to do with my code to get it working

    i want to keep the rest of the code the same as it works from sheet to sheet
    whats the best way to do it

  5. #5
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: copying to a new workbook

    is this anway closer
    or whats the best way to go bout it

     Dim wsMaster As Worksheet, wbDATA As Workbook
    Dim NextRow As Long, LastRow As Long
    
    Set wsMaster = ThisWorkbook.Sheets("allocation")
    NextRow = wsMaster.Range("A" & Rows.Count).End(xlUp).Row + 1
    
    Set wbDATA = Workbooks.Open("C:\Users\rr154237\Desktop\\UBS_FND_OngoingCharge_Calc.xlsx")
    
        With wbDATA.Sheets("allocation")
        
                   LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
              For i = 1 To LR
                 If IsDate(.Cells(i, 1)) Then
                     .Cells(i, 1).Copy
                    wsMaster.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
                End If
                    If Len(.Cells(i, "AD")) And .Cells(i, "AD") = "FUND OWNERSHIP %" Then
                    .Cells(i, "AD").Offset(1).Resize(4).Copy
                    wbDATA.Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
                  End If
              Next i
        End With
                    
    Application.CutCopyMode = 0
    Columns(1).NumberFormat = "dd/mm/yyyy"
    Application.ScreenUpdating = True
    
        
    
    'wbDATA.Close False
    End Sub
    i want to cpoy certain data from the spreadsheet the marco is in to\UBS_FND_OngoingCharge_Calc.xlsx

+ 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