VBA newbie, cant work out how to structure a loop

brooksie

New Member
Joined
Apr 6, 2011
Messages
7
Hi, Hopefully someone can point me in the right direction on how to structure a code to do the following (i'll try explain best i can)

below is an example of the kind of data im working with.. i've tried for / nexts loops within loops, creating variables to + 1 on rows, and all kinds of stuff but im stuggling and it never comes out as planned

a b c d
1 header1 header2 header3 header 4
2 green banana one two
3 green banana two three
4 green orange three four
5 green orange five six
6 red apple four one
7 red pear one two

i want to ...
-add color, next row down add the headers, next row - add all the data where b is the same (banana).. then new headers but under same color, then the next data in b (orange) with same color(green) then leave a row and start the new color. (as shown below)

a b c
1 Green
2 header2 header3 header4
3 banana one two
4 banana two three
5 header 2 header3 header4
6 orange three four
7 orange five six
8
9 red
10 header2 header3 header4
11 apple four one
12 pear one two

any assitance is appriciated ;)
Thanks
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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