Change Macro to look at name vs row range

Kim B

Board Regular
Joined
Jun 16, 2008
Messages
233
Office Version
  1. 365
Hi all. What is the simple way of telling a macro to split data at the point of a name change vs a row range. So instead of saying this
Rows("1:121").Select
Selection.Copy

say when name changes select
selection copy


Both ABC would be on the same sheet
Both XYZ would be on the same sheet

Name=ABC Fast Foods Portland Customer Group
Name=ABC Fast Foods Maine Customer Group
Name=XYZ Health Foods Chicago Customer Group
Name=XYZ Health Foods Delaware Customer Group

As always

Thank you
 

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.
S
Hi all. What is the simple way of telling a macro to split data at the point of a name change vs a row range. So instead of saying this
Rows("1:121").Select
Selection.Copy

say when name changes select
selection copy


Both ABC would be on the same sheet
Both XYZ would be on the same sheet

Name=ABC Fast Foods Portland Customer Group
Name=ABC Fast Foods Maine Customer Group
Name=XYZ Health Foods Chicago Customer Group
Name=XYZ Health Foods Delaware Customer Group

As always

Thank you

And what would happen after.
Are you saying ABC would be cut and pasted on sheet named ABC
And XYZ would be cut and pasted on sheet named XYZ.
 
Upvote 0
Cut and pasted in separate workbooks but the rest of the macro handles that ok. It is a recorded macro as the user is not familiar with vba at all. They just need to extract and group all the data for each company by name instead of row because the row numbers may change.
 
Upvote 0
Cut and pasted in separate workbooks but the rest of the macro handles that ok. It is a recorded macro as the user is not familiar with vba at all. They just need to extract and group all the data for each company by name instead of row because the row numbers may change.

What column are those company names located in? At the very least you should provide a screenshot of your workbook or upload a sample file. Without knowing what columns you're dealing with, no one will be able to give you a concise answer.

(You can also use XL2BB on the forums to show us your current worksheet setup.)
 
Upvote 0
Here is a screen shot, I don't have XL2BB at this location. There are merged columns beginning in row 8 (A-J). This may look familiar as a macro was built to split each break in customer regardless if it was the same customer. This user needs all same customer grouped into one workbook. They will not be unmerging. They have a macro doing what they want it to do they recorded but they don't know how to break the data based on name change vs row number which is how the recorded macro works.

1716231391819.png
 
Upvote 0
Sorry but I don't know how to help you. With those company names contained in merged cells, it's a headache and beyond my VBA capabilities.

It is far better to use 'Center Across Selection' method rather than merging cells. I only use the latter option only as a last resort.
 
Upvote 0

Forum statistics

Threads
1,224,760
Messages
6,180,816
Members
452,996
Latest member
nelsonsix66

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