Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello all,
I have a piece of code that creates an Array with my range of data and looks for a value in Column B, if the value equals a Declared string, then Drop a value in column ("O") if not, just grab the value from Column B and drop that in Column ("O").
The logic of the code seems fine and when hovering over any of my declared values I am seeing all the values I should be seeing, its only when I tell the code to populate column ("O") nothing seems to be happening?
Not sure what the issue is but hopefully someone will spot it.
I have a piece of code that creates an Array with my range of data and looks for a value in Column B, if the value equals a Declared string, then Drop a value in column ("O") if not, just grab the value from Column B and drop that in Column ("O").
The logic of the code seems fine and when hovering over any of my declared values I am seeing all the values I should be seeing, its only when I tell the code to populate column ("O") nothing seems to be happening?
Not sure what the issue is but hopefully someone will spot it.
Code:
'----------------------------------------------------------------------------------------
'--- Using the Group List by Titles tag each record with Unique Name
'----------------------------------------------------------------------------------------
Sub GroupTitles2()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Count As String, OriginalTitle As String, GroupTitle As String
Dim LastR1 As Long, LastR2 As Long
Dim VarArray As Variant
Dim i As Long, j As Long
Application.ScreenUpdating = False
Set ws1 = Sheets("Download")
Set ws2 = Sheets("Lookup")
LastR1 = ws1.Range("G" & Rows.Count).End(xlUp).Row
LastR2 = ws2.Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastR2
If ws2.Cells(i, 2) <> "" Then
OriginalTitle = ws2.Cells(i, 2).Value
GroupTitle = ws2.Cells(i, 3).Value
End If
VarArray = ws1.Range("A2:O" & LastR1).Value
For j = 1 To UBound(VarArray, 1)
If VarArray(j, 2) = OriginalTitle Then
VarArray(j, 15) = GroupTitle '<-----------------------------------This line won't drop a value?????
Else
VarArray(j, 15) = VarArray(j, 2) '<-----------------------------------This line won't drop a value?????
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub