View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default 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.