Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to make cells numeric only

Eight celles on my worksheet need to be numeric only, and if a user
inputs text into any of the 8 cells then, the key commands (or other
method) do not work. (or accepted)

Here is what i have managed to piece together so far from the help
files.


Private Sub Worksheet_Change(ByVal Target As Range)
dim cellok as boolean
Dim vdata As Range, Cell As Range
Set vdata = Range("b5,d5,f5,h5,j5,b9,d9,f9,h9,j9")
If IsNumeric(vdata.Cell).Value Then
cellOk
Else

End If
End Sub


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to make cells numeric only

IsNumeric will not evaluate a multicell range as you appear to be trying to
do. You need to check each cell individually.

Why not just use Validation under the data menu?

--
Regards,
Tom Ogilvy

mikewild2000 wrote in message
...
Eight celles on my worksheet need to be numeric only, and if a user
inputs text into any of the 8 cells then, the key commands (or other
method) do not work. (or accepted)

Here is what i have managed to piece together so far from the help
files.


Private Sub Worksheet_Change(ByVal Target As Range)
dim cellok as boolean
Dim vdata As Range, Cell As Range
Set vdata = Range("b5,d5,f5,h5,j5,b9,d9,f9,h9,j9")
If IsNumeric(vdata.Cell).Value Then
cellOk
Else

End If
End Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to make cells numeric only

Tom, what about the Len function, as this does not work either.

Dim vdata As Range, Cell As Range
Set vdata = Range("c7:j7")
If Len(vdata.Cell).Value Then
exit sub
end if
msgbox "blah blah"
end if
end su

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to make cells numeric only

There are not very many VBA functions (none I can think of) that will
evaluate multiple cells as an argument.

This is an illegal construct anyway: Len(vdata.Cell).Value

len returns a number - a number certainly doesn't have a Value property.

Dim bBad as Boolean
Dim cell as Range
bBad = False
for each cell in Range("c7:j7")
if not isnumeric(cell) then
bBad = True
exit sub
Next
if bBad then
msgbox "All data must be numeric"

End if

--
Regards,
Tom Ogilvy

mikewild2000 wrote in message
...
Tom, what about the Len function, as this does not work either.

Dim vdata As Range, Cell As Range
Set vdata = Range("c7:j7")
If Len(vdata.Cell).Value Then
exit sub
end if
msgbox "blah blah"
end if
end sub


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to make cells numeric only

Sorry to my fault

On the numeric topic i took you advice and used data\validate from th
tools menu.

But could the len function validate that a group of cells only have
numbers or less in each cell

--
Message posted from http://www.ExcelForum.com

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
finding only cells with a numeric value Eelinla Excel Discussion (Misc queries) 3 April 21st 07 07:01 PM
How did I make my column headings become numeric (1 2 3) averyemma New Users to Excel 1 February 22nd 07 03:57 PM
How do I make letters not show up in a alpha-numeric string? gdd6936 Excel Worksheet Functions 3 June 3rd 06 09:56 PM
Is it possible to make excel NOT process non-numeric cell data in formulae perfection Excel Discussion (Misc queries) 2 April 14th 06 06:46 AM
The colums changed from alpha to numeric how do you make it alpha worldmade Excel Discussion (Misc queries) 2 May 26th 05 03:44 PM


All times are GMT +1. The time now is 11:26 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"