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
 
I simulate you data in #1
G11 , T11 AR11
Person no, application.., Person decision
I've tested in here!! test ok
BTW What Office version you use?
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you excel does not like the last line let us try
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)
    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
And if you manged the modification
Here the two options for worsheet code
1_
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim a, b As Variant
    Dim i As Long
    Dim txt As String
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("AR:AR")) Is Nothing Then Exit Sub
    If (Target) <> "" Then
        a = Range("G11:G" & Cells(Rows.Count, 7).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(a)) = Application.Transpose(b)
        End With
    End If
End Sub
2_
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim a As Variant
    Dim i As Long
    Dim txt As String
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("AR:AR")) Is Nothing Then Exit Sub
    If (Target) <> "" Then
        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 If
End Sub
 
Upvote 0
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) 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
I get an out of memory error now. Working on it. Thank you for all of your help!
 
Upvote 0
How would you write the code if you are only seeing if the fill down is based on 1 field verses 2 fields. Maybe that's causing an issue. There were some modifications to the file and column counts so the person # is on column H and the fill down if entered is on column # 40 (an). I tried to modify the code below taking out the 2nd scenario.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim a, b As Variant
    Dim i As Long
    Dim txt As String
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("An:An")) Is Nothing Then Exit Sub
    If (Target) <> "" Then
        a = Range("H11:H").End(xlUp).Row).Resize(, 40)
        ReDim b(1 To UBound(a))
        With CreateObject("scripting.dictionary")
            For i = 1 To UBound(a)
                txt = a(i)
                If txt <> "" Then
                    If Not .exists(txt) Then
                        .Add txt, a(i, 40)
                        b(i) = a(i, 40)
                    Else
                        b(i) = .Item(txt)
                    End If
                End If
            Next
            Range("An11").Resize(UBound(a)) = Application.Transpose(b)
        End With
    End If
End Sub
 
Upvote 0
At the very beginning at least
VBA Code:
txt=a(i,1)
And
Code:
 a = Range("H11:H").End(xlUp).Row).Resize(, 40)
Should be
Code:
 a = Range("H11:H" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 40)
 
Last edited:
Upvote 0
And column AN in a array is 33 not 40
so
VBA Code:
If Not .exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i) = a(i, 33)
                    Else
 
Upvote 0
And column AN in a array is 33 not 40
so
VBA Code:
If Not .exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i) = a(i, 33)
                    Else
It's starting at column A, so wouldn't it be an array of 40? Or, does it count from the person # column?
 
Upvote 0

Forum statistics

Threads
1,216,519
Messages
6,131,132
Members
449,626
Latest member
Stormythebandit

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