#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default vba error

Hi All

This has to be easy for all you experts out there -- a userform with 2 text
boxes
entering a number or a zero in Tb2 the following code runs OK on running
the macro. leave it blank and the debugger kicks in is there a way round this
problem.
probably a msg telling them to enter a zero??

ws.Cells(iRow, 10).Value = Val(Trim(Me.Tb1.Value * 0.5)) +
Val(Trim(Me.Tb2.Value * 0.05))

--
Many thanks

hazel
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default vba error

I'd check to make sure that the values in the textboxes were numeric before I
tried to place the new value in the cell:

if isnumeric(me.tb1.value) _
and isnumeric(me.tb2.value) then
ws.cells(irow, ....
else
msgbox "please enter numbers"
end if


Hazel wrote:

Hi All

This has to be easy for all you experts out there -- a userform with 2 text
boxes
entering a number or a zero in Tb2 the following code runs OK on running
the macro. leave it blank and the debugger kicks in is there a way round this
problem.
probably a msg telling them to enter a zero??

ws.Cells(iRow, 10).Value = Val(Trim(Me.Tb1.Value * 0.5)) +
Val(Trim(Me.Tb2.Value * 0.05))

--
Many thanks

hazel


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default vba error

Hi To you both

Thanks you both turned up trumps, now works whatever the person enters in
the text boxes providing it is numeric -- no entry, macro runs on its merry
sweet way.and still finishes the job.
--
Many thanks

hazel


"Dave Peterson" wrote:

I'd check to make sure that the values in the textboxes were numeric before I
tried to place the new value in the cell:

if isnumeric(me.tb1.value) _
and isnumeric(me.tb2.value) then
ws.cells(irow, ....
else
msgbox "please enter numbers"
end if


Hazel wrote:

Hi All

This has to be easy for all you experts out there -- a userform with 2 text
boxes
entering a number or a zero in Tb2 the following code runs OK on running
the macro. leave it blank and the debugger kicks in is there a way round this
problem.
probably a msg telling them to enter a zero??

ws.Cells(iRow, 10).Value = Val(Trim(Me.Tb1.Value * 0.5)) +
Val(Trim(Me.Tb2.Value * 0.05))

--
Many thanks

hazel


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default vba error

try:

ws.Cells(iRow, 10).Value = Val(Me.Tb1.Value) * 0.5 +
Val(Me.Tb2.Value) * 0.05

"Hazel" wrote:

Hi All

This has to be easy for all you experts out there -- a userform with 2 text
boxes
entering a number or a zero in Tb2 the following code runs OK on running
the macro. leave it blank and the debugger kicks in is there a way round this
problem.
probably a msg telling them to enter a zero??

ws.Cells(iRow, 10).Value = Val(Trim(Me.Tb1.Value * 0.5)) +
Val(Trim(Me.Tb2.Value * 0.05))

--
Many thanks

hazel

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"