Sub PutThemThere()
Dim ws As Worksheet
Dim wb As Workbook
Dim rng As Range
Dim rCell As Range
Set ws = ActiveSheet
Set wb = Workbooks.Open("c:\file.xls")
With ws
Set rng = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
For Each rCell In rng.Cells
Select Case rCell.Value
Case "x"
rCell.Copy wb.Worksheets(1).Range(rCell.Address)
Case "y"
rCell.Copy wb.Worksheets(1).Range(rCell.Address)
Case "z"
rCell.Copy wb.Worksheets(1).Range(rCell.Address)
End Select
Next 'rCell
Set wb = Nothing
Set rng = Nothing
Set rCell = Nothing
Set ws = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
"Dan R." <(E-Mail Removed)>
wrote in message
I'm trying to loop down a column and copy and paste the values to
another wb depending on the cell value. Possibly something like this?
set ws = activesheet
set wb = workbooks.open("c:\file.xls")
set rng = .range(.cells(1, 1), .cells(rows.count, 1).end(xlup))
for each i in rng
select case cells(i, 1)
case "x"
cells(i, 1).copy wb.range("a1").paste
case "y"
cells(i, 1).copy wb.range("b1").paste
case "z"
cells(i, 1).copy wb.range("c1").paste
end select
next
Thanks,
-- Dan