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 can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

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
Back
Top