aliaslamy2k
Active Member
- Joined
- Sep 15, 2009
- Messages
- 416
- Office Version
- 2019
- Platform
- Windows
How to amend the below code so that the result should shown in coloums instead of rows.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> </o>
<o> </o>
<o> </o>
Example :
<TABLE style="MARGIN: auto auto auto 4.65pt; WIDTH: 58pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" class=MsoNormalTable border=0 cellSpacing=0 cellPadding=0 width=77><TBODY><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>AAA<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 1"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>BBB<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 2"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>CCC<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 3"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>DDD<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>EEE<o></o>
</TD></TR></TBODY></TABLE>
<o> </o>
<o> </o>
Instead of : AAA, BBB, CCC, DDD, EEE,<o></o>
<o> </o>
<o> </o>
Dim SearchColumn As Variant
Dim SearchRow As Variant
Dim ColumnCount As Long
Dim RowCount As Long
Dim FindColumn As Long
Dim FindRow As Long
Dim HitsCount As Long
ColumnCount = 0
RowCount = 0
HitsCount = 0
For Each SearchColumn In SearchRange.Columns
ColumnCount = ColumnCount + 1
If UCase(SearchColumn.Columns.Cells(1, 1).Value) = UCase(SearchHorizontal) Then
FindColumn = ColumnCount
End If
Next SearchColumn
For Each SearchRow In SearchRange.Rows
RowCount = RowCount + 1
If UCase(SearchRow.Rows.Cells(1, 1).Value) = UCase(SearchVertical) Then
FindRow = RowCount
If FindColumn = 0 Or FindRow = 0 Then
ARLOOKUP = 0
Else
HitsCount = HitsCount + 1
If HitsCount = 1 Then
ARLOOKUP = SearchRange.Cells(FindRow, FindColumn).Value
Else
ARLOOKUP = ARLOOKUP & ", " & SearchRange.Cells(FindRow, FindColumn).Value
End If
End If
End If
Next SearchRow
End Function
<o> </o>
Rgds,
AB
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> </o>
<o> </o>
<o> </o>
Example :
<TABLE style="MARGIN: auto auto auto 4.65pt; WIDTH: 58pt; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" class=MsoNormalTable border=0 cellSpacing=0 cellPadding=0 width=77><TBODY><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>AAA<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 1"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>BBB<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 2"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>CCC<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 3"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>DDD<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes"><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 58pt; PADDING-RIGHT: 5.4pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm; mso-border-left-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom width=77 noWrap>EEE<o></o>
</TD></TR></TBODY></TABLE>
<o> </o>
<o> </o>
Instead of : AAA, BBB, CCC, DDD, EEE,<o></o>
<o> </o>
<o> </o>
Dim SearchColumn As Variant
Dim SearchRow As Variant
Dim ColumnCount As Long
Dim RowCount As Long
Dim FindColumn As Long
Dim FindRow As Long
Dim HitsCount As Long
ColumnCount = 0
RowCount = 0
HitsCount = 0
For Each SearchColumn In SearchRange.Columns
ColumnCount = ColumnCount + 1
If UCase(SearchColumn.Columns.Cells(1, 1).Value) = UCase(SearchHorizontal) Then
FindColumn = ColumnCount
End If
Next SearchColumn
For Each SearchRow In SearchRange.Rows
RowCount = RowCount + 1
If UCase(SearchRow.Rows.Cells(1, 1).Value) = UCase(SearchVertical) Then
FindRow = RowCount
If FindColumn = 0 Or FindRow = 0 Then
ARLOOKUP = 0
Else
HitsCount = HitsCount + 1
If HitsCount = 1 Then
ARLOOKUP = SearchRange.Cells(FindRow, FindColumn).Value
Else
ARLOOKUP = ARLOOKUP & ", " & SearchRange.Cells(FindRow, FindColumn).Value
End If
End If
End If
Next SearchRow
End Function
<o> </o>
Rgds,
AB