VBA - Copying from hidden worksheet and inserting rows/pasting in seperate worksheet

tlc_in_OK

Board Regular
Joined
Jun 27, 2011
Messages
56
I have a hidden worksheet ("RawDataSheet") that pulls from a database, on which column "O" contains the month, i.e. August, September, etc., but not necessarily ALL months. I've written a short macro that finds the distinct months in "O" and copies/pastes them into another worksheet ("CurrentProjects") as headings in column A with a blank row beneath, but now I need to go back and find all the rows that contain/match each month heading, copy columns A thru E of those rows, and paste them underneath each of the headings.

There will always be a variable number of headings/months and rows---for example, currently I have 10 rows that would be copied under the "August" heading, and 13 under "September". But next week, I may have August, September, and October as months that were unique values from "O" on "RawDataSheet", and any number of rows associated with each.

It looks similar to this on "CurrentProjects" sheet I'm pasting to, after my macro copies the month unique values:
[TABLE="width: 470"]
<tbody>[TR]
[TD="class: xl65, width: 625, bgcolor: transparent, colspan: 5"]Sales Report
[/TD]
[/TR]
[TR]
[TD="class: xl66, bgcolor: #4F81BD"]DetailNumber
[/TD]
[TD="class: xl67, bgcolor: #4F81BD"]StreetAddress
[/TD]
[TD="class: xl67, bgcolor: #4F81BD"]City
[/TD]
[TD="class: xl67, bgcolor: #4F81BD"]StateProvince
[/TD]
[TD="class: xl67, bgcolor: #4F81BD"]ProjectName
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]August
[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]September

[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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