Macro that Auto Fills Down Based when text Entered on Matching Columns

squeakums

Well-known Member
Joined
May 15, 2007
Messages
823
Office Version
  1. 365
Here are the example details of what I need; all is on the same tab:

When someone types something in column E; I'd like this macro to activate and fill down that same answer if it matches the person number and application name. I will pay for this answer if I can. It's because these files are large and have over 200,000+ rows.

Thank you!

1603904314380.png
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi
Try this code!
VBA Code:
Sub test()
    Dim a,b As Variant
    Dim i As Long
    Dim txt As String
    a = Range("c11:c" & Cells(Rows.Count, 3).End(xlUp).Row).Resize(, 3)
    ReDim b(1 To UBound(a))
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
        txt = a(i, 1) & a(i, 2)
            If txt <> "" Then
                If Not .exists(txt) Then
                    .Add txt, a(i, 3)
                    b(i) = a(i, 3)
                    Else
                    b(i) = .Item(txt)
                End If
            End If
        Next
       Range("f11").Resize(UBound(b)) = Application.Transpose(b)
    End With
End Sub
 
Upvote 0
It seems to work and I appreciate your code :) Question is, how do you get it to work automatically as text is entered; like a private sub?
 
Upvote 0
I modified the code to match my real spreadsheet; for some reason it is deleting items that are lower like in rows 20 and lower; making those blank even though I am entering data. Perhaps I didn't change something in the code this time so it will flow with my new data.

For the two columns that need to match prior to fill down:
the person number is in column G; starting G11.
the application name is in column T; starting T11

where it needs to fill down is column AR; starting in AR11; count 38 over from column G

Did I update the code wrong below?

VBA Code:
Sub Fill()
    Dim a, b As Variant
    Dim i As Long
    Dim txt As String
    a = Range("g11:g" & Cells(Rows.Count, 38).End(xlUp).Row).Resize(, 38)
    ReDim b(1 To UBound(a))
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
        txt = a(i, 1) & a(i, 14)
            If txt <> "" Then
                If Not .exists(txt) Then
                    .Add txt, a(i, 38)
                    b(i) = a(i, 38)
                    Else
                    b(i) = .Item(txt)
                End If
            End If
        Next
       Range("ar11").Resize(UBound(b)) = Application.Transpose(b)
    End With
End Sub
 
Upvote 0
Well,
a = Range("g11:g" & Cells(Rows.Count, 38).End(xlUp).Row).Resize(, 38)
What is in Column 38?
Any way debug Array a can you
 
Upvote 0
Just Try to change
VBA Code:
a = Range("g11:g" & Cells(Rows.Count, 38).End(xlUp).Row).Resize(, 38)
To
VBA Code:
a = Range("g11:g" & Cells(Rows.Count, 7).End(xlUp).Row).Resize(, 38)
Or any full column, you know what I mean
 
Upvote 0
Any way
VBA Code:
Sub test()
    Dim a As Variant
    Dim i As Long
    Dim txt As String
    a = Range("G11:G" & Cells(Rows.Count, 7).End(xlUp).Row).Resize(, 38)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
        txt = a(i, 1) & a(i, 14)
            If txt <> "" Then
                If Not .exists(txt) Then
                    .Add txt, a(i, 38)
                    Else
                    a(i, 38) = .Item(txt)
                End If
            End If
        Next
       Range("AR11").Resize(UBound(a)) = Application.Index(a, 0, 38)
    End With
End Sub
New VERSION with your modi
 
Upvote 0
Any way, for resizing array (a) pick a column that goes to the end of your data not a short one
 
Upvote 0
Any way
VBA Code:
Sub test()
    Dim a As Variant
    Dim i As Long
    Dim txt As String
    a = Range("G11:G" & Cells(Rows.Count, 7).End(xlUp).Row).Resize(, 38)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
        txt = a(i, 1) & a(i, 14)
            If txt <> "" Then
                If Not .exists(txt) Then
                    .Add txt, a(i, 38)
                    Else
                    a(i, 38) = .Item(txt)
                End If
            End If
        Next
       Range("AR11").Resize(UBound(a)) = Application.Index(a, 0, 38)
    End With
End Sub
New VERSION with your modi
I received a weird type mismatch error on this one once I changed it:

1603915207173.png
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top