Grouping rows in Excel

Bren.ie

New Member
Joined
Aug 29, 2002
Messages
7
I have data imported into Excel. The data is arranged with a row detailing a product heading, followed immediatly by rows with product data, followed by a blank row separating the data from the next next product header, rows of data etc.

I there way I can segregate, for example all products ending with the letter S together with the data rows for that product, and delete all others.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
700
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
You copy this code into a VBA module and run to delete the blank rows.

Sub Data_Segregate()
Dim I
For I = 1 To 65536
If Range("A" & I) = "" Then ActiveCell.Cells.EntireRow.Delete
Next I

End Sub

You can change the Max value of I to match with your last row number containing data.

Write the following formula

For Ex. Product named "Bolts" in A1 and a number 500 in A2 is there in your worksheet
Then in B1 write the formula
=If(Right(Trim(A1),1)="S",A1)
in B2
=If(Right(Trim(A1),1)="S",A2)

GNaga
 

Forum statistics

Threads
1,144,274
Messages
5,723,444
Members
422,497
Latest member
dougy99

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
Top