PDA

View Full Version : Copy values from one sheet to another



Sreeja
04-16-2007, 03:29 AM
Hi ,
I am trying to copy values from one sheet to another on the bases of a particular column.
For eg : I have a worksheet with three sheets A,B and C... i want to copy the rows of Sheet A to Sheet B if the value of the columns = PL . If the value is anything other than PL then the row value should be copied to Sheet C.
I am attching the sample file which should be the result.
Pls help

Jacob Hilderbrand
04-23-2007, 09:20 PM
So something like:

If Sheets("Sheet A").Range("A1").Value = "PL" Then
Range("A1").EntireRow.Copy Destination:=Sheets("Sheet B").Range("A1")
Else
Range("A1").EntireRow.Copy Destination:=Sheets("Sheet C").Range("A1")
End If



The you just replace "A1" with a variable row like ("A" & i) within your loop.

Emoncada
07-18-2007, 06:34 AM
I am trying to make this work for me with no luck. I have a similar situation I need it to look at column "O" so if "O" has the value "1" then copy entire row and paste in sheet 2

lucas
07-18-2007, 06:39 AM
Post your workbook please

Emoncada
07-18-2007, 06:53 AM
This is the sheet. I would like to transfer the entire row of the one's that have a "1" in Column "O".

rory
07-18-2007, 07:12 AM
Try this:

Sub TransferIssues()
Dim wksSource As Worksheet, wksDest As Worksheet
Dim rngTarget As Range
Dim lngRow As Long, lngRowCount As Long
Set wksSource = Sheet1
Set wksDest = Sheet2
With wksSource
lngRowCount = .Cells(.Rows.Count, "O").End(xlUp).Row
End With
With wksDest
Set rngTarget = .Cells(.Cells(.Rows.Count, 15).End(xlUp).Row + 1, 1)
End With
For lngRow = 2 To lngRowCount
With wksSource.Cells(lngRow, "O")
If .Value = 1 Then
.EntireRow.Copy rngTarget
Set rngTarget = rngTarget.Offset(1, 0)
End If
End With
Next lngRow
End Sub


HTH
Rory

lucas
07-18-2007, 07:19 AM
Hi Em,
This should get you started. You will probably want to run a sort after the copy if you copy a lot of data....

lucas
07-18-2007, 07:22 AM
Now you have some options......