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
 
Okay there's the code I have based on what you said to change:

I'm getting an error on the one I have in red below. It is because I am trying to only run off 1 column (person #) and that rows.count 8 is throwing it off? Not sure what that rows count is. I feel like I am so close .. ah. Let me know if you want me to pay you for this and thanks!

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
      [COLOR=rgb(209, 72, 65)]  [B]Range("H11:H" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 33)[/B][/COLOR]
        ReDim b(1 To UBound(a))
        With CreateObject("scripting.dictionary")
            For i = 1 To UBound(a)
                txt = a(i, 1)
                If txt <> "" Then
                    If Not .exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i) = a(i, 33)
                    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

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Of course
VBA Code:
a = Range("a11:a" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 40)
 
Upvote 0
I changed the code but still getting an error:

script out of range for txt = a(I)

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("a11:a" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 33)
        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, 33)
                        b(i) = a(i, 33)
                    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
Okay, so I am playing with the code, and this one almost works at the top; except around row 48,000 it gives an #n/a for someones ID, it is also not one of the ones I changed?

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" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 40)
        ReDim b(1 To UBound(a))
        With CreateObject("scripting.dictionary")
            For i = 1 To UBound(a)
                txt = a(i, 1)
                If txt <> "" Then
                    If Not .exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i) = a(i, 33)
                    Else
                        b(i) = .Item(txt)
                    End If
                End If
            Next
            Range("An11").Resize(UBound(a)) = Application.Transpose(b)
        End With
    End If
End Sub

1603995430749.png
 
Upvote 0
Ahaa,
Well, I think this a limitation of Transpose Issue
I've some thing about this some where some time about overcome Transpose in excel
I'll Try to find it and will submitted to you.
So do not worry will be solved some how
 
Upvote 0
Try it like
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" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 40)
        ReDim b(1 To UBound(a), 1 To 1)
        With CreateObject("scripting.dictionary")
            For i = 1 To UBound(a)
                txt = a(i, 1)
                If txt <> "" Then
                    If Not .Exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i, 1) = a(i, 33)
                    Else
                        b(i, 1) = .Item(txt)
                    End If
                End If
            Next
            Range("An11").Resize(UBound(b)) = b
        End With
    End If
End Sub
 
Upvote 0
I was just thinking about it
But If you noticed
VBA Code:
 ReDim b(1 To UBound(a), 1 To 1)
So Ubound(a)= Ubound(b) , Right?
 
Upvote 0
Then
VBA Code:
 Range("An11").Resize(UBound(b)) = b
will Repeat first value all the way
While
Code:
Range("An11").Resize(UBound(a)) = Application.Transpose(b)
Gives right resule for small amount of rows
 
Upvote 0
Try it like
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" & Cells(Rows.Count, 8).End(xlUp).Row).Resize(, 40)
        ReDim b(1 To UBound(a), 1 To 1)
        With CreateObject("scripting.dictionary")
            For i = 1 To UBound(a)
                txt = a(i, 1)
                If txt <> "" Then
                    If Not .Exists(txt) Then
                        .Add txt, a(i, 33)
                        b(i, 1) = a(i, 33)
                    Else
                        b(i, 1) = .Item(txt)
                    End If
                End If
            Next
            Range("An11").Resize(UBound(b)) = b
        End With
    End If
End Sub
Eureka!!! I think it's finally working! THANK YOU THANK YOU THANK YOU! Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,250
Members
449,305
Latest member
Dalyb2

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