meledward23
New Member
- Joined
- Aug 2, 2016
- Messages
- 19
I am trying to copy and paste rows, based on a condition being meet to the last row of the sheet.
So basically what I am trying to do is:
Range("Assemselect") = cell k2, its a text value.
Column A - has matching values.
I want to copy the ENTIREROW of Column A when it matches.
Then paste it at the end. (Actually I think eventually I will want to insert before row 6, but I am undecided), that I believe I can handle.
Getting the copy paste to work correctly and run through the range is my issue.
this code just passes through one time and does nothing.
So basically what I am trying to do is:
Range("Assemselect") = cell k2, its a text value.
Column A - has matching values.
I want to copy the ENTIREROW of Column A when it matches.
Then paste it at the end. (Actually I think eventually I will want to insert before row 6, but I am undecided), that I believe I can handle.
Getting the copy paste to work correctly and run through the range is my issue.
this code just passes through one time and does nothing.
VBA Code:
Dim lrow As Long
Dim rng As Range
Dim rngrow As Range
lrow = Sheets("HS Template").Range("a" & Rows.Count).End(xlUp).Row 'find last row (ONLY VISBLE)
On Error Resume Next
For Each rngrow In Range("a1:a" & lrow).Rows 'sets rngrow to full visible range
If rngrow.Cells(1).Value = Range("assemselect").Value Then 'finds where column A = $k$2
With Sheets("HS TEMPLATE")
.rngrow.EntireRow.Copy
.Rows(lrow).Insert Shift:=x1down
End With
End If
Next rngrow