New to Error Handleing

P

pkohler

I am trying to write a macro to remove duplicate records from a cs
file. The problem that I am having is that I am trying to allow th
user to select a range via an input box:

dim check as range

Set check = Application.InputBox(prompt:="Select with the Mouse th
Area you would like to check for Duplicates.", Type:=8)

That works fine, but If the user hit's cancel then the the macro error
out with a runtime error 424 Object required.

Any Recomendations
 
B

Bob Phillips

Of course.

Dim Check As Range

On Error Resume Next
Set Check = Application.InputBox(prompt:="Select with the Mouse the Area you
would like to check for Duplicates.", Type:=8)
On Error Goto 0
If Not Check Is Nothing Then
'your codeEnd If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
P

pkohler

Thanks for that tip, it worked great! However I am running into a ne
problem. Sometimes, Mouse entry stops working. I.E. when you try t
click on the range, it doesn't let you. You can still type in a rang
though. It is seemingly random and when it happens you either need t
restart excel or restart your computer. Has anyone ever seen this
 
Top