Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Allow only numeric data in certain cells & only text strings in others


Any VBA code suggestion how to allow only numeric input in certain cell
& text string input in other cells of a particular worksheet other tha
using onentry. I need the VBA code to be in the sheet change cod
since other sheets exists in the same workbook.

For example:

Only allow numeric entries in cells F4 thru O5
Only allow text strings entries in cells F6 thru O6
Only allow numeric entries in cells F7 thru O7
Only allow text strings entries in cells F8 thru O8
Only allow numeric entries in cells F9 thru O9
Only allow text strings entries in cells F10 thru O10
etc.

Thanks so very much. mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=47181

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Allow only numeric data in certain cells & only text strings in ot

Why not use Data - Validation?
--
HTH...

Jim Thomlinson


"mikeburg" wrote:


Any VBA code suggestion how to allow only numeric input in certain cells
& text string input in other cells of a particular worksheet other than
using onentry. I need the VBA code to be in the sheet change code
since other sheets exists in the same workbook.

For example:

Only allow numeric entries in cells F4 thru O5
Only allow text strings entries in cells F6 thru O6
Only allow numeric entries in cells F7 thru O7
Only allow text strings entries in cells F8 thru O8
Only allow numeric entries in cells F9 thru O9
Only allow text strings entries in cells F10 thru O10
etc.

Thanks so very much. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471819


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Allow only numeric data in certain cells & only text strings in others


I could, but forgive me I am new to VBA, I'm thinking of something I a
working on that the input range will change from time to time.
Therefore, if I could learn to do this with VBA variables, I would no
have to do it manually. I am just having trouble getting the synta
down.

Thanks so much. mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=47181

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Allow only numeric data in certain cells & only text strings i

You can dynamically change the validation in code if that is what you need.
Generally using the built in feature is better than building your own from
scratch in this type of circumstance. But if a code solution is your
preference... You want to use the on change event. Test the target value to
validate that it is ok. If it fails the validation routine then use
application.undo & target.select to roll back the change along with a message
explaining to the user the error of their ways.
--
HTH...

Jim Thomlinson


"mikeburg" wrote:


I could, but forgive me I am new to VBA, I'm thinking of something I am
working on that the input range will change from time to time.
Therefore, if I could learn to do this with VBA variables, I would not
have to do it manually. I am just having trouble getting the syntax
down.

Thanks so much. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471819


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Allow only numeric data in certain cells & only text strings in others


I could, but forgive me I am new to VBA, I'm thinking of something I am
working on that the input range will change from time to time.
Therefore, if I could learn to do this with VBA variables, I would not
have to do it manually. I am just having trouble getting the syntax
down.

Thanks so much. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471819



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Allow only numeric data in certain cells & only text strings i

How is it coming along from my last post. Are you following my suggestion or
is the suggestion more baffling than the original problem...
--
HTH...

Jim Thomlinson


"mikeburg" wrote:


I could, but forgive me I am new to VBA, I'm thinking of something I am
working on that the input range will change from time to time.
Therefore, if I could learn to do this with VBA variables, I would not
have to do it manually. I am just having trouble getting the syntax
down.

Thanks so much. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471819


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Allow only numeric data in certain cells & only text strings in others


Sorry, but I am still having trouble coming up with an answer. I
thought it would
be a simple answer. I have been trying:
'For allowing numbers only
Range("F7:O7").NumberFormat = "@"

'Set Validation to Text
Range("F8:O8").Validation.Delete
Range("F8:O8").Validation.Add Type:=xlValidateTextLength, _
Operator:=xlBetween, Formula1:="0", Formula2:="15"

The problem I am having is numbers entered in Text cells F8:08 still
get totaled in with the sum total at the end of columns F, G, H, I, J,
K, L, M, & O.

I'm thinking that sheet change event code would be better but I am
still trying to figure out how. Can someone help me with above or the
sheet change event code? Thanks, mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471819

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
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
Identifying cells without certain text strings jay Excel Worksheet Functions 3 November 26th 07 01:59 AM
Replacing characters in numeric text strings and SUMming rkd Excel Discussion (Misc queries) 7 April 20th 06 12:25 PM
How to skip cells with text strings. mikeburg Excel Discussion (Misc queries) 1 August 6th 05 12:52 AM
Converting variable text strings to numeric Richgard53 Excel Discussion (Misc queries) 1 July 13th 05 06:22 AM


All times are GMT +1. The time now is 12:15 AM.

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"