ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning results to multiple location using VBA? (https://www.excelbanter.com/excel-programming/373821-returning-results-multiple-location-using-vba.html)

[email protected]

Returning results to multiple location using VBA?
 
Thanks for the help in advance!! The macro below compares data from a
range and lists all the possible permutations (combinations) of the
data.

EXAMPLE...the range of:

Price
MGP
Comfort
Style

will return this data:

Price <compared to MGP
Price <compared to Comfort
Price <compared to Style
MGP <compared to Comfort
MGP <compared to Style
Comfort <compared to Style


How can I alter the macro to ALSO return the data to another sheet and
aranged in a table?

EXAMPLE:

Price MGP Comfort Style
Price
MGP
Comfort
Style


Here is macro:

abc()
Dim rw As Long, i As Long, j As Long
Dim lb As Long, ub As Long
Dim rng As Range, icol As Long
Set rng = Range("c7:c10")
lb = rng(1).Row
ub = rng(rng.Count).Row
icol = rng.Column
rw = 6
For i = lb To ub
For j = i + 1 To ub
If StrComp(Cells(i, icol), Cells(j, icol), _
vbTextCompare) < 0 Then
rw = rw + 1
Cells(rw, icol + 1) = Cells(i, icol) & " <compared to
" & Cells(j, icol)
End If
Next
Next

End Sub



All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com