I have a list of names from Z2:Z19 and then a count formula in the cell next from AA2:AA19. The count formula counts how many times the name is left on a different worksheet. I am makeing a list on what is remaining. I have a formula to write it one by one but having issues on making 1 code to do it all. Below is what I have so far. Thanks for your time.
Private Sub CommandButton1_Click()
Range("a2:a500").Select
Selection.ClearContents
Dim arrValues() As Variant
Dim lngLastrow As Long
Dim intCol As Integer
i = Range("AA2").Value
x = Range("AA3").Value
If ActiveSheet.Range("A2") > "" Then
lngLastrow = ActiveSheet.Columns(1).Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Else
lngLastrow = 1
End If
ReDim arrValues(1 To 1, 1 To i)
For intCol = LBound(arrValues, 2) To UBound(arrValues, 2)
arrValues(1, intCol) = Range("Z2").Value
Next intCol
ActiveSheet.Cells(lngLastrow + 1, 1).Resize(UBound(arrValues, 2), 1).Value = Application.Transpose(arrValues)
If ActiveSheet.Range("A2") > "" Then
lngLastrow = ActiveSheet.Columns(1).Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Else
lngLastrow = 1
End If
ReDim arrValues(1 To 1, 1 To x)
For intCol = LBound(arrValues, 2) To UBound(arrValues, 2)
arrValues(1, intCol) = Range("Z3").Value
Next intCol
ActiveSheet.Cells(lngLastrow + 1, 1).Resize(UBound(arrValues, 2), 1).Value = Application.Transpose(arrValues)
End Sub
Private Sub CommandButton1_Click()
Range("a2:a500").Select
Selection.ClearContents
Dim arrValues() As Variant
Dim lngLastrow As Long
Dim intCol As Integer
i = Range("AA2").Value
x = Range("AA3").Value
If ActiveSheet.Range("A2") > "" Then
lngLastrow = ActiveSheet.Columns(1).Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Else
lngLastrow = 1
End If
ReDim arrValues(1 To 1, 1 To i)
For intCol = LBound(arrValues, 2) To UBound(arrValues, 2)
arrValues(1, intCol) = Range("Z2").Value
Next intCol
ActiveSheet.Cells(lngLastrow + 1, 1).Resize(UBound(arrValues, 2), 1).Value = Application.Transpose(arrValues)
If ActiveSheet.Range("A2") > "" Then
lngLastrow = ActiveSheet.Columns(1).Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Else
lngLastrow = 1
End If
ReDim arrValues(1 To 1, 1 To x)
For intCol = LBound(arrValues, 2) To UBound(arrValues, 2)
arrValues(1, intCol) = Range("Z3").Value
Next intCol
ActiveSheet.Cells(lngLastrow + 1, 1).Resize(UBound(arrValues, 2), 1).Value = Application.Transpose(arrValues)
End Sub