Formatting Groups with VBA

sjk1193

New Member
Joined
Nov 12, 2018
Messages
29
I have the table below and I need to write a VBA script to change table 1 so that the data looks like table B and pastes the data in a new tab in the same workbook

The only distinguishing features between the rows is that one is bold and the others are not. The Bold is the overall group and the ones that are not bolded are holdings in the groups.
So I basically need it to list the group and the holdings side by side

1
NameID
ABC1
def2
qwe3
plm4
yui5
MNB6
ert7
lkj8
rtyu9

<tbody>
</tbody>


2
ABCdef
ABCqwe
plmyui
MNBert
MNBlkj
MNBrtyu

<tbody>
</tbody>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this for results starting "D1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Nov27
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Dn.Font.Bold = True [COLOR="Navy"]Then[/COLOR]
        Temp = Dn.Value
    [COLOR="Navy"]ElseIf[/COLOR] Temp <> "" [COLOR="Navy"]Then[/COLOR]
        c = c + 1
        Cells(c, 4) = Temp
        Cells(c, 4).Font.Bold = True
        Cells(c, 5) = Dn.Value
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

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