Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Obtain the Range Name used for Data Validation

I need to aquire the name of the range that was used in Data Validation
programatically at runtime.

Many Thanks
--
Robert Hill

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 527
Default Obtain the Range Name used for Data Validation



"Robert" wrote:

I need to aquire the name of the range that was used in Data Validation
programatically at runtime.

Many Thanks
--
Robert Hill


Robert

Insert this code in the workbook module (right-click the Excel icon on the
on the file menu) and choose View Code.

Sub workbook_open()
Dim i As Integer, x
On Error Resume Next
Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
Worksheets(i).Select
x = ActiveCell.SpecialCells(xlCellTypeAllValidation).S elect
If IsEmpty(x) Then
' Do nothing
Else
MsgBox Selection.Address & vbLf & ActiveSheet.Name
End If
Next i
Worksheets(1).Select
Application.ScreenUpdating = False
End Sub

Tweak to suit

regards
Peter
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Obtain the Range Name used for Data Validation

Sub ABC()
Dim v As Validation
Dim rng As Range, s As String
Dim sName As String
Set v = Nothing
On Error Resume Next
Set v = ActiveCell.Validation
s = v.Formula1
On Error GoTo 0
If s < "" Then
If v.Type = xlValidateList Then
If InStr(1, v.Formula1, "=", vbTextCompare) Then
s = Replace(v.Formula1, "=", "")
Set rng = Application.Range(s)
On Error Resume Next
sName = rng.Name.Name
On Error GoTo 0
If sName = "" Then
MsgBox rng.Address
Else
MsgBox "Name range: " & sName
End If
Else
MsgBox "Hard coded list validation"
End If
Else
MsgBox "Validation is not of type list"
End If
Else
MsgBox "No validation"
End If
End Sub

Lightly tested.

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
I need to aquire the name of the range that was used in Data Validation
programatically at runtime.

Many Thanks
--
Robert Hill



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 527
Default Obtain the Range Name used for Data Validation

Thanks for the rating Robert

Peter

"Billy Liddel" wrote:



"Robert" wrote:

I need to aquire the name of the range that was used in Data Validation
programatically at runtime.

Many Thanks
--
Robert Hill


Robert

Insert this code in the workbook module (right-click the Excel icon on the
on the file menu) and choose View Code.

Sub workbook_open()
Dim i As Integer, x
On Error Resume Next
Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
Worksheets(i).Select
x = ActiveCell.SpecialCells(xlCellTypeAllValidation).S elect
If IsEmpty(x) Then
' Do nothing
Else
MsgBox Selection.Address & vbLf & ActiveSheet.Name
End If
Next i
Worksheets(1).Select
Application.ScreenUpdating = False
End Sub

Tweak to suit

regards
Peter

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Obtain the Range Name used for Data Validation

Robert,

I am an inexperienced user like yourself, however i have the same problem as
you i found that DAO works better with this than MS Query and ODBC (look it
up on the MS knowledge base), it took me a little while to follow it, but it
works so much better, you can even pass parameters back to Access etc. I
haven't figured out the SQL it needs to query as well as MS Query, so
personally i just make the query how i want it in Access and then pull that
through using DAO.

HTH.
Emma





"Robert" wrote:

I need to aquire the name of the range that was used in Data Validation
programatically at runtime.

Many Thanks
--
Robert Hill

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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Data Validation to range names for Chart Source Data Candyman Charts and Charting in Excel 1 September 3rd 09 07:27 PM
Need hyperlink function to obtain range name from a cell (contents DW Excel Worksheet Functions 4 January 12th 08 11:07 PM
Record macro and obtain variable range results? Pierre Excel Discussion (Misc queries) 2 August 18th 06 07:03 PM
How to obtain the shortest range that encloses all the non empty cells? faustino Dina Excel Programming 2 August 2nd 03 05:25 PM


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