Thanks in advance to everyone. I have the following code that allows me to select a list of names and post to a new range. It works well but my first pass was to just recreate code X times and change the selection criteria called REG to XXX and also change the variable to paste the selection to a new range DNRG_REG to DNRG_XXX. This is very inefficient having to run the procedures say 10 times but it works. I know there is an array approach and if anyone can point me in the right direction it would be great appreciated. I want to be able to setup variables and have the code loop through the each variable names and range for pasting. Thanks again.
Sub Tkr_REG()
'Find the last used row in a Column: column A in this example
Dim LastRow As Long
Dim i As Long, j As Long
With Worksheets("PosSrc")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Debug.Print LastRow
End With
''first row number where you need to paste values in Reg'
With Worksheets("PosSrc")
j = .Cells(.Rows.Count, DRNG_REG).End(xlUp).Row + 2
Debug.Print j
End With
For i = 1 To LastRow
With Worksheets("PosSrc")
If .Cells(i, 2).Value = "REG" And .Cells(i, 5).Value > 0 Then 'OR.Cells(i, 1).Value = 17 Then
.Cells(i, 1).Copy Destination:=Worksheets("PosSrc").Range(DRNG_REG & j)
j = j + 1
End If
End With
Next i
Sub Tkr_REG()
'Find the last used row in a Column: column A in this example
Dim LastRow As Long
Dim i As Long, j As Long
With Worksheets("PosSrc")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Debug.Print LastRow
End With
''first row number where you need to paste values in Reg'
With Worksheets("PosSrc")
j = .Cells(.Rows.Count, DRNG_REG).End(xlUp).Row + 2
Debug.Print j
End With
For i = 1 To LastRow
With Worksheets("PosSrc")
If .Cells(i, 2).Value = "REG" And .Cells(i, 5).Value > 0 Then 'OR.Cells(i, 1).Value = 17 Then
.Cells(i, 1).Copy Destination:=Worksheets("PosSrc").Range(DRNG_REG & j)
j = j + 1
End If
End With
Next i