+ Reply to Thread
Results 1 to 10 of 10

Copy from one workbook to another

  1. #1
    Alen32
    Guest

    Copy from one workbook to another

    I want to copy from workbook (C:\bonus.xls) rows where column A equal "0021
    DE" or ""0020 DE" and column C equal "DE1100" to workbook(C:\departure.xls)
    and sheet1.
    But only rows from colum F,G, and L.


  2. #2
    Bob Phillips
    Guest

    Re: Copy from one workbook to another

    Sub Control()

    Workbooks("c:|\bonus.xls").Open
    Workbooks("c:\departure.xls").Open
    CopyData 6
    CopyData 7
    CopyData 12

    End SUb



    Sub CopyData(col as long)
    Dim iLastRow As Long

    With Workbooks("bonus.xls").Worksheets("Sheet1")
    iLastRow = .Cells(.Rows.Count,col).End(xlUp).Row
    For i = 1 To iLastRow
    If .Cells(i,col).Value ="0020 DE" Or _
    .Cells(i,col).Value = "0021 DE" Then
    .cells(i,col).entirerow.copy _

    Workbooks("departure.xls").Worksheets("Sheet1").cells(i,"A")
    End If
    Next i
    End With

    End SUb


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Alen32" <[email protected]> wrote in message
    news:[email protected]...
    > I want to copy from workbook (C:\bonus.xls) rows where column A equal

    "0021
    > DE" or ""0020 DE" and column C equal "DE1100" to

    workbook(C:\departure.xls)
    > and sheet1.
    > But only rows from colum F,G, and L.
    >




  3. #3
    Alen32
    Guest

    Re: Copy from one workbook to another

    I get error message : "subscript out of range"


  4. #4
    Bob Phillips
    Guest

    Re: Copy from one workbook to another

    Sorry, error here

    Sub Control()

    Workbooks("c:\bonus.xls").Open
    Workbooks("c:\departure.xls").Open
    CopyData 6
    CopyData 7
    CopyData 12

    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Sub Control()
    >
    > Workbooks("c:|\bonus.xls").Open
    > Workbooks("c:\departure.xls").Open
    > CopyData 6
    > CopyData 7
    > CopyData 12
    >
    > End SUb
    >
    >
    >
    > Sub CopyData(col as long)
    > Dim iLastRow As Long
    >
    > With Workbooks("bonus.xls").Worksheets("Sheet1")
    > iLastRow = .Cells(.Rows.Count,col).End(xlUp).Row
    > For i = 1 To iLastRow
    > If .Cells(i,col).Value ="0020 DE" Or _
    > .Cells(i,col).Value = "0021 DE" Then
    > .cells(i,col).entirerow.copy _
    >
    > Workbooks("departure.xls").Worksheets("Sheet1").cells(i,"A")
    > End If
    > Next i
    > End With
    >
    > End SUb
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Alen32" <[email protected]> wrote in message
    > news:[email protected]...
    > > I want to copy from workbook (C:\bonus.xls) rows where column A equal

    > "0021
    > > DE" or ""0020 DE" and column C equal "DE1100" to

    > workbook(C:\departure.xls)
    > > and sheet1.
    > > But only rows from colum F,G, and L.
    > >

    >
    >




  5. #5
    Alen32
    Guest

    Re: Copy from one workbook to another

    still doesn't work samme error "subscript out of range"


  6. #6
    Bob Phillips
    Guest

    Re: Copy from one workbook to another

    <blush> completely wrong syntax

    Sub Control()

    Workbooks.Open Filename:="c:\bonus.xls"
    Workbooks.Open Filename:="c:\departure.xls"
    CopyData 6
    CopyData 7
    CopyData 12

    End Sub

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Alen32" <[email protected]> wrote in message
    news:[email protected]...
    > still doesn't work samme error "subscript out of range"
    >




  7. #7
    Alen32
    Guest

    Re: Copy from one workbook to another

    Now is working but makro copy entire rows not only three columns


  8. #8
    Bob Phillips
    Guest

    Re: Copy from one workbook to another

    Sorry, I thought you asked for entire column.

    Shoulg F,G,L go tgo A,B,C or F,G,L?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Alen32" <[email protected]> wrote in message
    news:[email protected]...
    > Now is working but makro copy entire rows not only three columns
    >




  9. #9
    Alen32
    Guest

    Re: Copy from one workbook to another

    f,g,l to a,b,c


  10. #10
    Bob Phillips
    Guest

    Re: Copy from one workbook to another

    Sub Control()

    Workbooks.Open Filename:="c:\bonus.xls"
    Workbooks.Open Filename:="c:\departure.xls"
    CopyData 6,"A"
    CopyData 7,"B"
    CopyData 12,"C"

    End Sub
    Sub CopyData(col As Long,target As String)
    Dim iLastRow As Long

    With Workbooks("bonus.xls").Worksheets("Sheet1")
    iLastRow = .Cells(.Rows.Count,col).End(xlUp).Row
    For i = 1 To iLastRow
    If .Cells(i,col).Value ="0020 DE" Or _
    .Cells(i,col).Value = "0021 DE" Then

    Workbooks("departure.xls").Worksheets("Sheet1").cells(i,target) = _
    .cells(i,col).Value
    End If
    Next i
    End With

    End SUb



    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Alen32" <[email protected]> wrote in message
    news:[email protected]...
    > f,g,l to a,b,c
    >




+ 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