Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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").ce lls(i,"A")
End If
Next i
End With

End SUb


--

HTH

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


"Alen32" wrote in message
lkaboutsoftware.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Copy from one workbook to another

I get error message : "subscript out of range"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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").ce lls(i,"A")
End If
Next i
End With

End SUb


--

HTH

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


"Alen32" wrote in message
lkaboutsoftware.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Copy from one workbook to another

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
lkaboutsoftware.com...
still doesn't work samme error "subscript out of range"



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Copy from one workbook to another

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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
lkaboutsoftware.com...
Now is working but makro copy entire rows not only three columns



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Copy from one workbook to another

f,g,l to a,b,c

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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").ce lls(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" wrote in message
lkaboutsoftware.com...
f,g,l to a,b,c



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
Copy cells based on conditions in one workbook to another workbook fLiPMoD£ Excel Discussion (Misc queries) 0 August 1st 07 07:43 PM
Need a macro to copy a range in one workbook and paste into another workbook Paul Excel Programming 8 July 1st 04 07:42 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"