NicheD
09-26-2022, 03:20 AM
Hello, I have two columns (C and D) filled with values. If column D is more than zero but less than 10 i want the cell (and cell C from the same row) to be picked. I cannot get this to work. Any suggestions?
Dim lrowD As Long, frowD As Long, i As Long
Dim arr As Variant
Dim rng As Range
Dim Col1 as String
With ActiveSheet
frowD = .Cells(.Rows.Count, "D").End(xlUp).Row - 14
lrowD = .Cells(.Rows.Count, "D").End(xlUp).Row - 3
Set rng = ActiveSheet.Range(.Cells(frowD, "B"), .Cells(lrowD, "D"))
arr = rng
For i = 1 To UBound(arr)
If arr(i, 3) > 0 and arr(i, 3) < 10 Then
Col1 = Col1 & arr(i, 2) & vbNewLine & arr(i, 3)
End If
Next i
end with
Dim lrowD As Long, frowD As Long, i As Long
Dim arr As Variant
Dim rng As Range
Dim Col1 as String
With ActiveSheet
frowD = .Cells(.Rows.Count, "D").End(xlUp).Row - 14
lrowD = .Cells(.Rows.Count, "D").End(xlUp).Row - 3
Set rng = ActiveSheet.Range(.Cells(frowD, "B"), .Cells(lrowD, "D"))
arr = rng
For i = 1 To UBound(arr)
If arr(i, 3) > 0 and arr(i, 3) < 10 Then
Col1 = Col1 & arr(i, 2) & vbNewLine & arr(i, 3)
End If
Next i
end with