Dave Peterson
2/8/2009 1:30:00 PM
I see that now.
It usually a good idea to indicate the line that actually causes the error.
Else each responder may see problems in other portions and correct that.
(That's what happened to me!)
cellist wrote:
>
> Dave, thanks for your reply. Turns out it was a different kind of problem in
> this case, but your suggestion is right on as a defensive programming device.
>
> "Dave Peterson" wrote:
>
> > I'd check both those variables.
> >
> > dim OkToCalc as boolean
> >
> > OkToCalc = true
> > if isnumeric(hours) = false then
> > msgbox "hours not numeric"
> > oktocalc = false
> > end if
> > if isnumeric(days) = false then
> > msgbox "days not numeric"
> > oktocalc = false
> > else
> > if days = 0 then
> > msgbox "Days is 0--division by 0 not possible"
> > oktocalc = false
> > end if
> > end if
> >
> > if oktocalc then
> > holOptElig = hours / days
> > else
> > 'what should happen here?
> > end if
> >
> > cellist wrote:
> > >
> > >
> > > Dim days As Variant
> > > Dim hours As Variant
> > > Dim holOptElig As Variant
> > > Dim wb As Workbook
> > > Set wb = Workbooks("Salary and Hourly Summary 2009.xls")
> > > days = wb.Names("MikeNbrHolidays").Value
> > > hours = wb.Names("MikeTotalHolHours").Value
> > > If days > 0 Then
> > > holOptElig = hours / days <== error on this statement
> > > End If
> > >
> > > In "Salary and Hourly Summary 2009.xls", MikeNbrHolidays and
> > > MikeTotalHolHours are formatted as number/0 decimal places and
> > > number/1 decimal places respectively, and their values are 8 and
> > > 43.2. I get run time error 13, type mismatch when I run this code.
> > >
> > > TIA,
> > >
> > > Phil
> >
> > --
> >
> > Dave Peterson
> >
--
Dave Peterson