cells which are contain same tags, they should come in one group.

PANKAJUTEKAR

Board Regular
Joined
Jun 10, 2011
Messages
79
Hi,
Very Good Morning to All Members,

This query has solved my little bit problem, but still i didnt understand how to group it. And also, it may be difficult to explain you or make you to understand what kind of o/p require.

Therefore, I request if any Experts or Members do not understand the part kindly let me know.

My Problem is - cells which are contain same tags, they should come in one group.

I have two sheets now. (this sheet is not fixed, sometimes it may 4 or 3 or 1)
In Col B, there are no tags. (this is fixed property)
eg.-
P1-150-KM-004-1
P1-150-PM-001A-1
P2-150-EA-001-KM03
6P-150-JB-001 (sometime it 6p also)
C-LU-150-EA-001-KM02-2
P2-150-KM-004-1
.
.
P2-150-PM-001A-1
.
.
C-LU-150-KM-004-1
.
.
P-150-KM-004-2

In the above example - 1,
P1-150-KM-004-1
P2-150-KM-004-1
C-LU-150-KM-004-1 (sometimes no. 2 wire also there), sometimes this "c" dosent exist.
P-150-KM-004-2

In the above example - 2,
P1-150-PM-001A-1
P2-150-KM-004-1
that' it. some have this is much only.

This should come one below one. B'coz this is one set. But this is came randmoly any where, not sorted properly.

How we can sort?
By this "P1", b'coz 150-KM-004-1 this is same this have no problem. (my point of view)

so my problem is this, all this tags comes in set with their tags.

Is this possible?

All Experts..

What i coded was -
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim obj As Worksheet
Dim i
Dim k, mLoop As Boolean, mloop1 As Boolean
Dim lintRow As Long
Dim xlwksh As Worksheet
On Error GoTo errorLoop
mLoop = False
mloop1 = False

For k = 1 To Worksheets.Count
'Debug.Print k & " ---" & Worksheets.Item(k).Name & " ----- " & Worksheets.Count
Worksheets.Item(k).Activate

If ((UCase(Worksheets.Item(k).Name) = "NOTES") Or (Worksheets.Item(k).Name = "Cover page") Or (Worksheets.Item(k).Name = "SPReport_Definition") Or (Worksheets.Item(k).Name = "SPReport_OriginalSheet1")) Then
Worksheets.Item(k).Tab.ColorIndex = 4
Else
Set xlwksh = ThisWorkbook.Worksheets(k)

'this is contains worksheet name "Cable list" + value cell c5 eg- "Cable list 1550" worksht name
xlwksh.Name = "Cable list" & "(" & ThisWorkbook.Worksheets(k).Cells(5, 3) & ")"


Range("a11").Select
Range(Cells(11, 1), Selection.End(xlDown)).Select
p = Selection.Rows.Count
Debug.Print p

For i = 11 To p

If (Left(Cells(i, 2), 1) = "6" And Mid(Cells(i, 2), 3, 1) = "1") Then
Cells(i, 50) = 1
ElseIf (Left(Cells(i, 2), 1) = "6" And Mid(Cells(i, 2), 3, 1) = "2") Then
Cells(i, 50) = 2
ElseIf (Left(Cells(i, 2), 1) = "6" And Mid(Cells(i, 2), 3, 1) = "-") Then Cells(i, 50) = 3
ElseIf (Left(Cells(i, 2), 1) = "P" And Mid(Cells(i, 2), 2, 1) = "1") Then Cells(i, 50) = 4
ElseIf (Left(Cells(i, 2), 1) = "P" And Mid(Cells(i, 2), 2, 1) = "2") Then Cells(i, 50) = 5
ElseIf (Left(Cells(i, 2), 1) = "P" And Right(Cells(i, 2), 1) = "1") Then Cells(i, 50) = 6
ElseIf (Left(Cells(i, 2), 1) = "P" And Right(Cells(i, 2), 1) = "2") Then Cells(i, 50) = 7
ElseIf (Left(Cells(i, 2), 1) = "P" And Right(Cells(i, 2), 1) = "3") Then Cells(i, 50) = 8
ElseIf (Left(Cells(i, 2), 1) = "P" And Right(Cells(i, 2), 1) = "4") Then Cells(i, 50) = 9
ElseIf (Left(Cells(i, 2), 1) = "P" And Mid(Cells(i, 2), 2, 1) = "-") Then Cells(i, 50) = 10
ElseIf (Left(Cells(i, 2), 1) = "C" And Right(Cells(i, 2), 1) = "1") Then Cells(i, 50) = 11
ElseIf (Left(Cells(i, 2), 1) = "C" And Right(Cells(i, 2), 1) = "2") Then Cells(i, 50) = 12
Else
Cells(i, 50) = 13
End If

Next i

Range(Cells(11, 1), Cells(p + 10, 50)).Select

Selection.Sort Key1:=Range("AW11"), Order1:=xlAscending, Key2:=Range( _
"AQ11"), Order2:=xlAscending, Key3:=Range("AX11"), Order3:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Worksheets.Item(k).Tab.ColorIndex = 4
Range("B11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="/2", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("B11").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:="/1", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False




End If
Next k

Exit Sub

 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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