View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Data Validation, Need text any length no spaces

A very simple worksheet change macro will do the trick

sub worksheet_change(Target as range)

target.value = trim(target.value)

end sub

this will only work on one worksheet. Go to tab on bottom of worksheet
(normally sheet1) and right click. Select view code. Place the 3 lines
above in VBA window. You may want ot restrict the trimming of spaces to only
a range of cells. Then use this

sub worksheet_change(Target as range)

if (target.row = 5) and (target.row <= 10) and _
(target.column = 3) and (target.column <= 20) then

target.value = trim(target.value)
end if

end sub


"BB" wrote:

I'd like to know if anyone knows how to set up data validation so that
a user is forced to enter text without spaces. For example:

J 23 45 should be J2345

I'm not concerned about placing restrictions on the length, just that
there are no spaces in the text entered.

Any help someone could offer would be appreciated.

Thanks,
BB