Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can someone look at the new code and tell me why it does
not work. It copies all rows with the work Ard in the worksheet called Ard but it seems to be pasting each row copied to the same row in the destination. I thought that a counter would help this. Do I have it in the wrong place? I think I have tried everywhere. THANKS FOR THE HELP. Dim RNG As Range, rng1 As Range Dim cell As Range Counter = 0 With Worksheets(2) On Error Resume Next Set RNG = .Range(.Cells(2, "L"), _ Cells(Rows.Count, "L").End(xlUp)) Set rng1 = RNG.SpecialCells(xlConstants) On Error GoTo 0 Counter = 0 If Not rng1 Is Nothing Then For Each cell In RNG Counter = 2 If .Cells(cell.Row, "L").Value Like "Ard" Then Rows(cell.Row).Copy Sheets("Ard").Rows(Counter) .Cells(cell.Row, "L").Value = "ARD" End If Counter = Counter + 2 Next End If End With |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think it's he
Counter = 0 If Not rng1 Is Nothing Then For Each cell In RNG Counter = 2 If .Cells(cell.Row, "L").Value Like "Ard" Then Rows(cell.Row).Copy Sheets("Ard").Rows(Counter) .Cells(cell.Row, "L").Value = "ARD" End If Counter = Counter + 2 Next End If Everytime you change cells, the counter gets reset to 2. Maybe: Counter = 1 If Not rng1 Is Nothing Then For Each cell In RNG If .Cells(cell.Row, "L").Value Like "Ard" Then Rows(cell.Row).Copy Sheets("Ard").Rows(Counter) .Cells(cell.Row, "L").Value = "ARD" counter = counter + 1 'or +2 End If Next End If rl_davis wrote: Can someone look at the new code and tell me why it does not work. It copies all rows with the work Ard in the worksheet called Ard but it seems to be pasting each row copied to the same row in the destination. I thought that a counter would help this. Do I have it in the wrong place? I think I have tried everywhere. THANKS FOR THE HELP. Dim RNG As Range, rng1 As Range Dim cell As Range Counter = 0 With Worksheets(2) On Error Resume Next Set RNG = .Range(.Cells(2, "L"), _ Cells(Rows.Count, "L").End(xlUp)) Set rng1 = RNG.SpecialCells(xlConstants) On Error GoTo 0 Counter = 0 If Not rng1 Is Nothing Then For Each cell In RNG Counter = 2 If .Cells(cell.Row, "L").Value Like "Ard" Then Rows(cell.Row).Copy Sheets("Ard").Rows(Counter) .Cells(cell.Row, "L").Value = "ARD" End If Counter = Counter + 2 Next End If End With -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy workbook to 2nd workbook paste is greyed out | Excel Worksheet Functions | |||
Copy and Paste between workbook | Excel Discussion (Misc queries) | |||
Copy and Paste from ANOTHER WORKBOOK | Excel Discussion (Misc queries) | |||
copy and paste using code from workbook to workbook | Excel Discussion (Misc queries) | |||
I cannot paste from one workbook to another. Copy works, paste do. | Excel Discussion (Misc queries) |