Jerry138889
New Member
- Joined
- May 23, 2013
- Messages
- 28
Hey.
I'm trying to make a new worksheet with data for every change in Customer name. So, for example, the below table would represent the raw data on sheet 1. I want the macro to create a new worksheet whenever the Customer Name changes i.e. (Customer Name) =/= (Customer Name -1).
I want sheet 2 to have XYZ's data only, sheet 3 to have TUNIJM's data only, sheet 4 to have SGFG etc.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Customer Name[/TD]
[TD][/TD]
[TD]Currency[/TD]
[TD]Account Type[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]Y[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]TUNIJM Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]TUNIJM Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
</tbody>[/TABLE]
I've been looking around the forum for a bit and have come up (possibly) with parts of the code I'm looking for. The macro could name the new worksheet after the Customer Name too, but that is not a priority.
I've tried to fiddle about with this and replace some text in the macro but I'm probably not substituting properly and I don't really understand what I'm doing!
I appreciate any help.
I'm trying to make a new worksheet with data for every change in Customer name. So, for example, the below table would represent the raw data on sheet 1. I want the macro to create a new worksheet whenever the Customer Name changes i.e. (Customer Name) =/= (Customer Name -1).
I want sheet 2 to have XYZ's data only, sheet 3 to have TUNIJM's data only, sheet 4 to have SGFG etc.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Customer Name[/TD]
[TD][/TD]
[TD]Currency[/TD]
[TD]Account Type[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]XYZ Ltd[/TD]
[TD][/TD]
[TD]Y[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]TUNIJM Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]TUNIJM Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]£[/TD]
[TD]Priority[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]SGFG Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]$[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]UKBN Ltd[/TD]
[TD][/TD]
[TD]€[/TD]
[TD]Normal[/TD]
[TD]1000[/TD]
[/TR]
</tbody>[/TABLE]
I've been looking around the forum for a bit and have come up (possibly) with parts of the code I'm looking for. The macro could name the new worksheet after the Customer Name too, but that is not a priority.
I've tried to fiddle about with this and replace some text in the macro but I'm probably not substituting properly and I don't really understand what I'm doing!
Code:
If Range("A" & Rw) <> Range("A" & Rw - 1) Then
For cnt = 1 To sh
Sheets(sh).Insert
I appreciate any help.