VBA Fill missing information

notrealname

New Member
Joined
Nov 24, 2011
Messages
14
Hi,
Searching for help to automatically fill missing information in column E where cells in column D match:
[TABLE="width: 557"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Control Number[/TD]
[TD]Control[/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD]Critical Spares for Girth Gear [/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071879[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD]Perform maintenance tasks to detect misalignment and deficient grease[/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]50071878[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
if you created a table of number and control on a separate sheet, then you could use vba to run down the list where missing and insert the relevant information on blanks
 
Upvote 0
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG03Apr50
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Q [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("D2"), Range("D" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Not .Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
   .Add Dn.Value, Array(Dn, Dn.Offset(, 1).Value)
[COLOR="Navy"]Else[/COLOR]
    Q = .Item(Dn.Value)
        [COLOR="Navy"]Set[/COLOR] Q(0) = Union(Q(0), Dn)
        Q(1) = Q(1) & Dn.Offset(, 1).Value
    .Item(Dn.Value) = Q
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]Dim[/COLOR] K [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
    .Item(K)(0).Offset(, 1).Value = Trim(.Item(K)(1))
[COLOR="Navy"]Next[/COLOR] K
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
MickG appears to be offline, but try

Code:
Sub MG03Apr50()
Dim Rng As Range, Dn As Range, n As Long, Q As Variant
Set Rng = Range(Range("D2"), Range("D" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
   .Add Dn.Value, Array(Dn, Dn.Offset(, 1).Value)
Else
    Q = .Item(Dn.Value)
        Set Q(0) = Union(Q(0), Dn)
        Q(1) = Q(1) & Dn.Offset(, 1).Value
    .Item(Dn.Value) = Q
End If
Next
Dim K As Variant
For Each K In .keys
    .Item(K)(0).Offset(, 1).Value = Trim(.Item(K)(1))
Next K
[color=red]End With[/color]
End Sub
 
Upvote 0
Thanks Michael !!
I've made that copying error once or twice lately. I think a slight rethink is required !!!
Regrds Mick
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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