Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validate Excel Range with RegEx

Any thoughts on how to validate an Excel range with RegEx?
Acceptable inputs would include $A1:$BD25, C:C, B4 etc.
I'm close to coming up with an answer but I'm not sure how to stop
invalid range references such as C3:A2 from being accepted.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Validate Excel Range with RegEx

You could try something like this. But be aware that "C3:A2" is a perfectly
valid range string. Even thought Excel will turn it around for
presentation/display purposes that doesn't mean it's invalid.

Sub Test()
MsgBox RgValid("ZC3:A2")
End Sub

Function RgValid(RgStr) As Boolean
Dim Rg As Range
On Error GoTo ExitThis
Set Rg = Range(RgStr)
RgValid = True
Exit Function
ExitThis:
End Function


--
Jim Rech
Excel MVP


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
automated cut and paste using regex excel_newbie Excel Worksheet Functions 2 March 20th 09 12:29 PM
validate a date range tikchye_oldLearner57 Excel Discussion (Misc queries) 4 March 13th 07 01:17 AM
Validate date within range prior to calculation Natassja Excel Discussion (Misc queries) 1 January 24th 06 05:52 PM
Regex Question William Barnes Excel Programming 5 January 2nd 04 11:57 AM
regex string matching Jamie Martin[_2_] Excel Programming 3 September 26th 03 09:28 PM


All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"