View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default Type Mismatch...

Roedd <<Darin Kramer wedi ysgrifennu:

Hi there,

I get a type mismatch error on the following line of code : "Set
objCell = Application.Selection" (see below)

Any idea why and how to fix ... (I swear it used to work!!!)

Thanks!!!!
D


Sub Reporting_Choice()

Dim objWS As Excel.Worksheet
Dim objCell As Excel.Range, objR As Excel.Range
Dim i As Byte
Dim J As Long

Set objWS = Sheets("Master")

Set objCell = Application.Selection


If your current selection is not a cell then of course this will raise an
error.

You need to ensure that a cell is selected:

If Typeof application.selection is Range then

<run your code
else
<display error message???

End if

HTH

Rob