LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Validate Cell Character Length with VBA

Hello All,

Trying to validate 6 characters in column N. This one used to work
but for some reason it's failing. Has a inputbox for user to make
correction with. I need to apply this to other columns with different
length requirements. All assistance greatly appreciated. Thanks, Ron

Sub ValdateData()
'validate values in a column
Range("N11").Select
Range(Selection, Selection.End(xlDown)).Select


Set Rng = Selection
FirstRow = Rng.Row
LastRow = Rng.Rows(Rng.Rows.Count).Row


Col = "n"
'loop thru col n of database, but skip first row with headings
For i = FirstRow To LastRow
If Len(Range("a1")(i, Col).Value) < 6 Then
FixColumnB
End If
Next i


End Sub


Sub FixColumnB()
'Enter a new value in Column B
Range("a1")(i, Col).Select
123456


Range("a1")(i, Col) = InputBox("Enter a 6 digit value")


'check to ensure six digits entered
If Len(Range("a1")(i, Col).Value) < 6 Then
FixColumnB
End If

End Sub
 
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
Predefined Cell Character Length Matt Excel Worksheet Functions 4 March 5th 09 10:21 PM
deleting a cell based on character length? Marcusdmc Excel Programming 2 August 7th 07 08:15 PM
assigning character length in a cell Audrey Excel Discussion (Misc queries) 4 July 30th 06 04:40 PM
How do I limit the character length of a cell when typing Andy Excel Programming 1 July 27th 05 03:54 PM
length of character data Saravanan Excel Discussion (Misc queries) 2 December 19th 04 06:49 PM


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