Perform compare of multiple selected columns

D

domleg

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.
 
P

Per Jessen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top