View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
[email protected] adam_kroger@hotmail.com is offline
external usenet poster
 
Posts: 20
Default Using named Excel range in VBA

I have ranges named cat1r, cat2r, cat3r... cat28r on multiple
worksheets inside my workbook. I am trying to format the number style
of the ranges based upon the contents of corresponding combo boxes on
a "setup" worksheet.

sub Type1_click ()
format_change( "cat1r", type1.value)
end sub

sub Type2_click () ' ---------------------there
are 28 boxes and 28 range names
format_change( "cat2r", type2.value)
end sub
------

Sub format_change (MyRng as range, MyType as string)
dim MyShts
MyShts = array (........................ ' load array with
names of worksheets
if MyType= "Time"
For i = 0 to 15
With Sheets(MyShts(i)).Range(MyRng).Validation
<SNIP ' -----------
Validate to dropdown using time 0:00 to 8:00 by :15
Else
For i = 0 to 15
With Sheets(MySht(i)).Range(CATr1).Validation
<SNIP '
-------------------- Validate to 0-999
End If
End Sub

I keep gettinng a runtime error at the With statement in regards to
the range name.
please help