ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Perform compare of multiple selected columns (https://www.excelbanter.com/excel-programming/438589-perform-compare-multiple-selected-columns.html)

domleg

Perform compare of multiple selected columns
 
I am looking for a way to program the following using VBA and a command button:

If user selected columns 4, 7 and 8 then compare this
if cells(2,4) = cells(2,7) = cells(2,8) then cell(2,12) = "ok"
else cell(2,12) = "check"

Basically, how can I get the column number of what columns are selected to
compare all data for each column selected.

Per Jessen

Perform compare of multiple selected columns
 
Hi

This should get you started:

Sub aaa()
For Each col In Selection.Columns
c = c + 1
Select Case c
Case 1
col1 = col.Column
Case 2
col2 = col.Column
Case 3
col3 = col.Column
End Select
Next
Debug.Print col1 & ", " & col2 & ", " & col3
End Sub

Regards,
Per

"domleg" skrev i meddelelsen
...
I am looking for a way to program the following using VBA and a command
button:

If user selected columns 4, 7 and 8 then compare this
if cells(2,4) = cells(2,7) = cells(2,8) then cell(2,12) = "ok"
else cell(2,12) = "check"

Basically, how can I get the column number of what columns are selected to
compare all data for each column selected.




All times are GMT +1. The time now is 08:58 AM.

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