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: 5
Default Trouble with dynamic named range

Hopefully there is a solution to my quandary this time. I am trying to
evaluate cells in a list to confirm that they are in a validation list.
Yes, I know that validation should have been used during entry, but it
was circumvented and I want to cycle through the cells and highlight
any that are not in the validation list.

My problem is that the following example code works when addressing a
range by cell reference (i.e. "c2:c9") and with a defined name range
that is limited (i.e. Shifts = "f3:f6"). But when I make the defined
name range dynamic, it stops working (i.e. Shifts =
offset(f3,0,0,counta(f3:f100),1) ). The cell loop goes across the
entire sheet, as it was from a more complicated example.

Could someone please explain what I am missing here?

Sub checkvalidation()
Dim LastRow As Long, LastCol As Long, rowstep As Long, colstep As Long,
validtype As Long
Dim validrng As Range

Application.EnableEvents = False
Application.ScreenUpdating = False

On Error GoTo errhandler

LastRow = Cells.SpecialCells(xlLastCell).Column
LastCol = Cells.SpecialCells(xlLastCell).Column

On Error Resume Next

For colstep = 1 To Last Col
For rowstep = 1 To LastRow
validtype = Cells(rowstep, colstep).Validation.Type
If validtype = 3 Then
Set validrng = Range("shifts")
If
IsError(Application.WorksheetFunction.Match(Cells( rowstep, colstep),
validrng, 0)) Then
With Cells(rowstep, colstep)
.Interior.ColorIndex = 45
End With
End If
End If
Next rowstep
Next colstep

errhandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub

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
Dynamic Named Range dhstein Excel Discussion (Misc queries) 4 October 11th 09 11:15 PM
Dynamic Named Range [email protected] Excel Discussion (Misc queries) 0 November 20th 07 03:08 PM
Dynamic Named Range bountifulgrace Charts and Charting in Excel 1 April 6th 06 08:39 PM
getting the absolute range address from a dynamic named range junoon Excel Programming 2 March 21st 06 01:29 PM
dynamic named range Steph[_3_] Excel Programming 3 March 22nd 05 02:56 PM


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