PDA

View Full Version : Need help with Excel Macro - InRange??



pincivma
04-22-2006, 03:12 PM
Hi there

This is an Excel question. I'm not so sure if it can be done or not.

I want the user to select a Cell in Column C before executing a macro. If any other cell is selected in any other column, except column C then I want a MsgBox saying "Please select an Account Number in Column C." When the user clicks on the OK button on the MsgBox, the macro exits. The user then selects and Account Number in Column C and then executes the macro.

Thanks,

Mario

Jacob Hilderbrand
04-22-2006, 03:50 PM
Try this:


Option Explicit

Sub Macro1()

Dim Prompt As String
Dim Title As String

If Intersect(ActiveCell, Range("C:C")) Is Nothing Then
Prompt = "Please select an Account Number in Column C."
Title = "Procedure Canceled"
MsgBox Prompt, vbCritical, Title
GoTo ExitSub:
End If

'The Rest Of Your Macro Here

ExitSub:

End Sub