Combining 8 columns into 5

MarkBeau

New Member
Joined
Jun 21, 2017
Messages
3
Hi

Option A is what I have on my screen which has 500 rows of data and not all rows have information in columns F G & H, option B is what I'm wishing to achieve. Is there a way of achieving this without VBA, if so would appreciate if you can advise. If VBA is the answer can someone assist. My VBA skills are limited plus I wish to understand what the scripting means so any comments on the scripting would be appreciated.

Thanks Mark


ABCDEFGH
OPTION A
1

Relationship TypeCompany Name/Last nameContact 1 - First NameContact 1 - Last NameContact 1 - EmailContact 2 - First NameContact 2 - Last NameContact 2 - Email
2SolicitorThe Law FirmFredSmithfred.smith@thelawfirm.com.auJohnBrownjohn.brown@thelawfirm.com.au
3AccountantBean CounterCriag Tomscraig.tome@beancounters.com
4Real EstateHot PropertyDavidJonesdjones@hotproperty.com.auAnneHayesanne.hayes@hotproperty.com.au
OPTION B
1Relationship TypeCompany Name/Last nameContact 1 - First NameContact 1 - Last NameContact 1 - Email
2SolicitorThe Law FirmFredSmithfred.smith@thelawfirm.com.au
3SolicitorThe Law FirmJohnBrownjohn.brown@thelawfirm.com.au
4AccountantBean CounterCriag Tomscraig.tome@beancounters.com
5Real EstateHot PropertyDavidJonesdjones@hotproperty.com.au
6Real EstateHot PropertyAnneHayesanne.hayes@hotproperty.com.au

<colgroup><col width="124" style="width:93pt"> <col width="174" style="width:131pt"> <col width="144" style="width:108pt" span="2"> <col width="213" style="width:160pt"> <col width="144" style="width:108pt"> <col width="141" style="width:106pt"> <col width="215" style="width:161pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi. There will be lots of different ways but heres one:

Code:
Dim sh As Worksheet, lr As Long, a As Long, arr
Set sh = Sheets("Sheet1") 'sheet name with data
lr = sh.Range("A" & Rows.Count).End(xlUp).Row 'last row of data
a = 2 'first row to use to place new data
arr = sh.Range("A2:H" & lr) 'get data into array
For i = LBound(arr, 1) To UBound(arr, 1) 'loop through array
    sh.Range("J" & a) = arr(i, 1)
    sh.Range("K" & a) = arr(i, 2)
    sh.Range("L" & a) = arr(i, 3)
    sh.Range("M" & a) = arr(i, 4)
    sh.Range("N" & a) = arr(i, 5)
    If Len(arr(i, 6)) > 0 Then 'check if name 2 exists
        a = a + 1
        sh.Range("J" & a) = arr(i, 1)
        sh.Range("K" & a) = arr(i, 2)
        sh.Range("L" & a) = arr(i, 6)
        sh.Range("M" & a) = arr(i, 7)
        sh.Range("N" & a) = arr(i, 8)
    End If
    a = a + 1
Next
 
Upvote 0
Hi Mark,

Can you something like this? I will you a very simple set a data. Assume your first set of emails is in A1:A4 and your second set of emails is in C1:C4. Assume your new column title is in A7. Place your formula in A7. This formula works. You need to use Cntrl+Shift+Enter.
=IFERROR(INDEX($A$1:$A$4,MATCH(0,COUNTIF($A$7:A7,$A$1:$A$4),0)),INDEX($C$1:$C$4,MATCH(0,COUNTIF($A$7:A7,$C$1:$C$4),0))) copy down.

<tbody>
</tbody>

Hope this helps.
Mike Szczesny
 
Upvote 0
Mike

At the end of the formula you have count down, as it is outside the formula does it represent something...Thanks Mark

=IFERROR(INDEX($A$1:$A$4,MATCH(0,COUNTIF($A$7:A7,$A$1:$A$4),0)),INDEX($C$1:$C$4,MATCH(0,COUNTIF($A$7:A7,$C$1:$C$4),0))) copy down.
 
Upvote 0

Forum statistics

Threads
1,216,175
Messages
6,129,300
Members
449,499
Latest member
HockeyBoi

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