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.
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.
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.
>
I get error message : "subscript out of range"
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.
> >
>
>
still doesn't work samme error "subscript out of range"
<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"
>
Now is working but makro copy entire rows not only three columns
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
>
f,g,l to a,b,c
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
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks