User needs to choose 2 columns on the fly

DChambers

Active Member
Joined
May 19, 2006
Messages
257
I am trying to write a macro that:
When run will ask the user to choose a column in the first sheet then choose a column in the second sheet.
Will compare the data in the first cell of the first sheet to the first cell in the second sheet and color the second sheets cell red if it is not the same.

I dont know what columns will be selected beforehand, perhaps the MsgBox function could be used?

thanks
Darrell
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

take a look at
InputBox (application)
see TYPEargument
Code:
Option Explicit

Sub select_in_single_column()
'Erik Van Geit
'050719 0044
Dim rng As Range

Selection(1).Select

    Do
    Set rng = Nothing
    On Error Resume Next
    Set rng = Application.InputBox(prompt:="Select a cell in the column", _
    Title:="SELECTION", Default:=ActiveCell.Address, Type:=8)
    On Error GoTo 0
    
        If rng Is Nothing Then
        Exit Sub
        Else
            If rng.Columns.Count > 1 Then
            MsgBox "please select in a SINGLE column", 48, "ERROR"
            Set rng = Nothing
            End If
        End If
    Loop While rng Is Nothing

End Sub

kind regards,
Erik
 

Forum statistics

Threads
1,136,370
Messages
5,675,369
Members
419,567
Latest member
Naveen27mech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top