ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create List based on Cell Value (https://www.excelbanter.com/excel-programming/399095-create-list-based-cell-value.html)

Steve[_4_]

Create List based on Cell Value
 
Hello. I'm trying to Scan column C for the word "Yes". If it finds
it, copy the contents of column R of the same row, and create a list
in Sheet2 one under the other.

Ideally, I would aslo love to have only unique values. Maybe that can
be done after the full list is created?

Thanks so much!!


JW[_2_]

Create List based on Cell Value
 
One way. This returns unique values and places them in the first
available row in column A of sheet 2.
Sub uniqueList()
Dim uVal As Collection, u As Variant
Set uVal = New Collection
For i = 2 To Cells(Rows.Count, 3).End(xlUp).Row
If UCase(Cells(i, 3).Text) = "YES" Then
On Error Resume Next
uVal.Add Cells(i, 18).Text, _
CStr(Cells(i, 18).Text)
On Error GoTo 0
End If
Next i
If uVal.Count = 0 Then Exit Sub
With Sheets("Sheet2")
For Each u In uVal
.Cells(.Rows.Count, 1).End(xlUp) _
.Offset(1, 0).Value = u
Next u
End With
Set uVal = Nothing
End Sub
Steve wrote:
Hello. I'm trying to Scan column C for the word "Yes". If it finds
it, copy the contents of column R of the same row, and create a list
in Sheet2 one under the other.

Ideally, I would aslo love to have only unique values. Maybe that can
be done after the full list is created?

Thanks so much!!




All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com