Column match
Solved/Closed
Related:
- Column match
- Music match jukebox - Download - Audio playback
- Excel column number - Guide
- Partial match excel - Guide
- Csgo custom match commands - Guide
- How to delete a column in word - Guide
2 responses
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
17 May 2010 à 05:27
17 May 2010 à 05:27
Can this data be sorted ?
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
18 May 2010 à 06:52
18 May 2010 à 06:52
try this. there is a function and a sub. You need to run sub MultiLevelAlign
Sub MultiLevelAlign()
Dim lMaxRowsL As Long
Dim lMaxRowsR As Long
Dim sBCol As String
Dim sJCol As String
Dim vSpaceL As String
Dim vSpaceR As String
Dim valueL As String
Dim valueR As String
sBCol = "B"
sJCol = "J"
lMaxRowsL = Cells(Rows.Count, "A").End(xlUp).Row
lMaxRowsR = Cells(Rows.Count, "I").End(xlUp).Row
With Range(sBCol & "2:" & sBCol & lMaxRowsL)
.FormulaR1C1 = "=LEN(RC1)-LEN(myTrim(RC1,""L""))"
.Copy
.PasteSpecial xlPasteValues
End With
With Range(sJCol & "2:" & sJCol & lMaxRowsR)
.FormulaR1C1 = "=LEN(RC9)-LEN(myTrim(RC9,""L""))"
.Copy
.PasteSpecial xlPasteValues
End With
lMaxRowsL = 2
Do While (lMaxRowsL <= lMaxRowsR)
valueL = Cells(lMaxRowsL, "A")
valueR = Cells(lMaxRowsL, "I")
vSpaceL = Cells(lMaxRowsL, sBCol)
vSpaceR = Cells(lMaxRowsL, sJCol)
If (vSpaceL = vSpaceR) Then
If valueL > valueR Then
Range("I" & lMaxRowsL & ":" & sJCol & lMaxRowsL).Insert Shift:=xlDown
lMaxRowsR = lMaxRowsR + 1
ElseIf valueL < valueR Then
Range("A" & lMaxRowsL & ":" & sBCol & lMaxRowsL).Insert Shift:=xlDown
Else
End If
ElseIf (vSpaceL > vSpaceR) Then
Range("I" & lMaxRowsL & ":" & sJCol & lMaxRowsL).Insert Shift:=xlDown
lMaxRowsR = lMaxRowsR + 1
ElseIf (vSpaceL < vSpaceR) Then
Range("A" & lMaxRowsL & ":" & sBCol & lMaxRowsL).Insert Shift:=xlDown
End If
lMaxRowsL = lMaxRowsL + 1
Loop
Range(sBCol & ":" & sBCol).Clear
Range(sJCol & ":" & sJCol).Clear
End Sub
Function myTrim(myString, Optional trimType As String = "") As String
Select Case UCase(trimType)
Case Is = "L"
myTrim = LTrim(myString)
Case Is = "R"
myTrim = RTrim(myString)
Case Is = ""
myTrim = Trim(myString)
Case Else
myTrim = "#NAME?"
End Select
End Function
17 May 2010 à 17:46
17 May 2010 à 17:57
17 May 2010 à 18:03
18 May 2010 à 01:31
Could you please upload a sample file with sample data etc on some shared site like https://authentification.site , http://wikisend.com/ , http://www.editgrid.com etc and post back here the link to allow better understanding of how it is now and how you foresee.
18 May 2010 à 02:03
columns.xls