Need a solution to club data from multiple columns and prepare a unique list

Siddhu11011

Board Regular
Joined
Jun 22, 2022
Messages
56
Office Version
  1. 365
Platform
  1. Windows
I have couple of columns in which accounts and account names are listed as below. I just need a solution to consolidate data from front 6 columns into last 2 columns.
ex: 1st, 3rd, and 5th columns are combined into 2nd last column and likewise for Account Names. Last 2 columns are having unique list of line items.
It would be helpful and delighted moment for me if you could just guide me with appropriate solution.

Account NumberAccount NameAccount NumberAccount NameAccount NumberAccount NameAccount NumberAccount Name
1254Shahid12458Taylorcadda3333Dinesh1254Shahid
D148Rahildf5846ReyonSsd54SureshD148Rahil
1496Sajidaw2546fRajeshsDs54Michel1496Sajid
D148Rahilaasf21531Rameshasds655Tom12458Taylor
ASas131Sairacadda3333Dineshdf5846Reyon
xazcsd32123Kiaraaw2546fRajesh
ss31Jenishaasf21531Ramesh
aasd131PankitASas131Saira
df5846Reyonxazcsd32123Kiara
aw2546fRajeshss31Jenish
aasd131Pankit
cadda3333Dinesh
Ssd54Suresh
sDs54Michel
asds655Tom
 
Try this:

VBA Code:
Option Explicit
Sub Siddhu11011_V7()
    Application.ScreenUpdating = False
    
    '   Clear columns AC:AD of data
    Range("AC2:AD" & Cells.Find("*", , xlFormulas, , 1, 2).Row).ClearContents
    
    '   Copy data to columns AC:AD
    Dim LRow As Long, Source
    Range("AC1").Resize(1, 2).Value = Array("Account Number", "Account Name")
    LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    For Each Source In Array("B2", "K2", "T2")
        With ActiveSheet.Range(Source).SpillingToRange
            Range("AC" & LRow).Resize(.Rows.Count, 2) = .Value
        End With
        LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    Next Source
    
    '   Remove the duplicates
    Range("AC:AD").RemoveDuplicates Columns:=2, Header:=xlYes
    Range("AC1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this:

VBA Code:
Option Explicit
Sub Siddhu11011_V7()
    Application.ScreenUpdating = False
 
    '   Clear columns AC:AD of data
    Range("AC2:AD" & Cells.Find("*", , xlFormulas, , 1, 2).Row).ClearContents
 
    '   Copy data to columns AC:AD
    Dim LRow As Long, Source
    Range("AC1").Resize(1, 2).Value = Array("Account Number", "Account Name")
    LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    For Each Source In Array("B2", "K2", "T2")
        With ActiveSheet.Range(Source).SpillingToRange
            Range("AC" & LRow).Resize(.Rows.Count, 2) = .Value
        End With
        LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    Next Source
 
    '   Remove the duplicates
    Range("AC:AD").RemoveDuplicates Columns:=2, Header:=xlYes
    Range("AC1").Select
    Application.ScreenUpdating = True
End Sub

Try the code in post #21 and let me knoI need

Try the code in post #21 and let me know how it goes.
It goes very well. One last help please please - Can you remove column headings for AC1 and AD1 which are account number and name?
 
Upvote 0
One last help please please - Can you remove column headings for AC1 and AD1 which are account number and name?
This should do it.
VBA Code:
Option Explicit
Sub Siddhu11011_V8()
    Application.ScreenUpdating = False
    
    '   Clear columns AC:AD of data
    Range("AC1:AD" & Cells.Find("*", , xlFormulas, , 1, 2).Row).ClearContents
    
    '   Copy data to columns AC:AD
    Dim LRow As Long, Source
    Range("AC1").Resize(1, 2).Value = Array("Account Number", "Account Name")
    LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    For Each Source In Array("B2", "K2", "T2")
        With ActiveSheet.Range(Source).SpillingToRange
            Range("AC" & LRow).Resize(.Rows.Count, 2) = .Value
        End With
        LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    Next Source
    
    '   Remove the duplicates
    Range("AC:AD").RemoveDuplicates Columns:=2, Header:=xlYes
    Range("AC1:AD1").ClearContents
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
This should do it.
VBA Code:
Option Explicit
Sub Siddhu11011_V8()
    Application.ScreenUpdating = False
   
    '   Clear columns AC:AD of data
    Range("AC1:AD" & Cells.Find("*", , xlFormulas, , 1, 2).Row).ClearContents
   
    '   Copy data to columns AC:AD
    Dim LRow As Long, Source
    Range("AC1").Resize(1, 2).Value = Array("Account Number", "Account Name")
    LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    For Each Source In Array("B2", "K2", "T2")
        With ActiveSheet.Range(Source).SpillingToRange
            Range("AC" & LRow).Resize(.Rows.Count, 2) = .Value
        End With
        LRow = Columns("AC:AC").Resize(, 2).Find("*", , xlFormulas, , 1, 2).Row + 1
    Next Source
   
    '   Remove the duplicates
    Range("AC:AD").RemoveDuplicates Columns:=2, Header:=xlYes
    Range("AC1:AD1").ClearContents
    Application.ScreenUpdating = True
End Sub
You are a Rockstar! What a concreate solution. Thank you so much for treating me patiently and your great help!
 
Upvote 0

Forum statistics

Threads
1,216,562
Messages
6,131,422
Members
449,651
Latest member
Jacobs22

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