VBA Help - Array Loop Won't Populate Cell????

Johnny Thunder

Well-known Member
Apr 9, 2010
Office Version
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.

'--- 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?????
                VarArray(j, 15) = VarArray(j, 2) '<-----------------------------------This line won't drop a value?????
            End If
        Next j

Next i
Application.ScreenUpdating = True
End Sub

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.


Well-known Member
Dec 3, 2018
Office Version
I think I sent you the solution to this thread but in another one of your thread.
The macro I put you uses arrays.
As I mentioned you should give examples to understand the process.

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...