I have a spreadsheet with 15 worksheets containing data for 21 cities. Some cities have multiple entries on their worksheet as they are separated by either north, south, etc... or uptown, downtown, etc...
New York - Bronx
New York - Queens
New York - Brooklyn
New York - Staten Island
as an example as they all reside on the New York worksheet. All 15 worksheets will have 100% identical table column headers.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]City/Network[/TD]
[TD]Group[/TD]
[TD]Position[/TD]
[TD]Foo[/TD]
[TD]Stuff
[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]xyz[/TD]
[TD]abc[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]def[/TD]
[TD]pqr[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]asdf[/TD]
[TD]asdf[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]wer vd[/TD]
[TD]asdf [/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3254[/TD]
[TD]ghjk[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]qwre[/TD]
[TD]tyu[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]asdf[/TD]
[TD]789[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]mno[/TD]
[TD]srt[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]4536asf[/TD]
[TD]a43[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]asdf v[/TD]
[TD]3425[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]2345[/TD]
[TD]2436[/TD]
[/TR]
</tbody>[/TABLE]
That could be an example of some data. Note that both the group and position values are identical, thus I will need to filter based on the column City/Network before I can look at the Group and Position and other column headers for data to extract.
I am not looking to paste any data into this workbook, just pull data out of the workbook to populate another workbook. The row values will change and are unique for each worksheet as would be expected for a network of city data. The position and group columns will have many duplicate data values as all networks have a minimum number of groups and each group has a minimum number of positions.
Looking for New York group 1 if not filtered further can result in 20 data sets (hope I am using that term here correctly) instead of the specific data set desired of New York - Queens group 1. That output based on the table above should have 4 rows worth of data for its data set. That is the range of cells I need to copy data from. Sadly I cannot just .value=.value the entire data set as I only need sections of the data. Once I am able to user the table column headers as part of the .Cells([searched_for_row_value],[table_column_header]).value it will be easy enough to copy/paste (.value=.value) between the 2 workbooks, I hope.
I have some copy/paste code that i have used in the past, but it is all hard codded to the .Cells(12, 2) as an example.
Notice the comment 18 July, 2019 had to hard code from row 12 down to row 15. That is they type of editing I would like to avoid (I know rows and columns are not the same for table headers) for this next project as new columns may be added down the road.
Thank you in advance.
Excel 2010 & 2016
New York - Bronx
New York - Queens
New York - Brooklyn
New York - Staten Island
as an example as they all reside on the New York worksheet. All 15 worksheets will have 100% identical table column headers.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]City/Network[/TD]
[TD]Group[/TD]
[TD]Position[/TD]
[TD]Foo[/TD]
[TD]Stuff
[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]xyz[/TD]
[TD]abc[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]def[/TD]
[TD]pqr[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]asdf[/TD]
[TD]asdf[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]wer vd[/TD]
[TD]asdf [/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]1[/TD]
[TD]3254[/TD]
[TD]ghjk[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]qwre[/TD]
[TD]tyu[/TD]
[/TR]
[TR]
[TD]New York - Bronx[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]asdf[/TD]
[TD]789[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]mno[/TD]
[TD]srt[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]4536asf[/TD]
[TD]a43[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]asdf v[/TD]
[TD]3425[/TD]
[/TR]
[TR]
[TD]New York - Queens[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]2345[/TD]
[TD]2436[/TD]
[/TR]
</tbody>[/TABLE]
That could be an example of some data. Note that both the group and position values are identical, thus I will need to filter based on the column City/Network before I can look at the Group and Position and other column headers for data to extract.
I am not looking to paste any data into this workbook, just pull data out of the workbook to populate another workbook. The row values will change and are unique for each worksheet as would be expected for a network of city data. The position and group columns will have many duplicate data values as all networks have a minimum number of groups and each group has a minimum number of positions.
Looking for New York group 1 if not filtered further can result in 20 data sets (hope I am using that term here correctly) instead of the specific data set desired of New York - Queens group 1. That output based on the table above should have 4 rows worth of data for its data set. That is the range of cells I need to copy data from. Sadly I cannot just .value=.value the entire data set as I only need sections of the data. Once I am able to user the table column headers as part of the .Cells([searched_for_row_value],[table_column_header]).value it will be easy enough to copy/paste (.value=.value) between the 2 workbooks, I hope.
I have some copy/paste code that i have used in the past, but it is all hard codded to the .Cells(12, 2) as an example.
Code:
' ================================================================ ' Code to copy NETWORK from Overview sheet to new group Worksheet.
' ================================================================
j = 2 ' Reset j back to 2.
' Sets starting point for copy/paste of data to correct Cell.
Set rFoundCell = Worksheets("overview").Range("A1")
' Starts for loop to search for 'start' vaule on the Overview Worksheet in the NETWORK column.
For lCount = 1 To Application.WorksheetFunction.CountIf(Worksheets("overview").Range("a1:a200"), start)
' Finds the 'start' value on the Overview Worksheet in the NETWORK column.
Set rFoundCell = Worksheets("overview").Columns(1).Find(what:=start, after:=rFoundCell, LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
' Start of the copy/paste data from Overview to new Group # Worksheet in a transpose form.
With rFoundCell
' The offset will move the source from column A to column H.
Worksheets("overview").Range(rFoundCell.Address).Offset(, 7).Copy
Worksheets("group " & start).Activate
' .Cells(12, j) moves down to Row 12. - 06-18-2018 procedure
' 18 July, 2019 procedure now row 15 - .Cells(15, j)
Worksheets("group " & start).Cells(15, j).PasteSpecial xlPasteValues
j = j + 1
End With
Next lCount ' End loop for copy NETWORK.
Notice the comment 18 July, 2019 had to hard code from row 12 down to row 15. That is they type of editing I would like to avoid (I know rows and columns are not the same for table headers) for this next project as new columns may be added down the road.
Thank you in advance.
Excel 2010 & 2016