ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Allow only numeric data in certain cells & only text strings in others (https://www.excelbanter.com/excel-programming/341478-allow-only-numeric-data-certain-cells-only-text-strings-others.html)

mikeburg[_33_]

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


Jim Thomlinson[_4_]

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



mikeburg[_34_]

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


mikeburg[_35_]

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


Jim Thomlinson[_4_]

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



Jim Thomlinson[_4_]

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



mikeburg[_37_]

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



All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com