View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Naming different ranges in the same column

Hi Denys,

Am Wed, 15 Apr 2015 10:56:09 -0700 (PDT) schrieb :

I forgot to mention that in the combobox the list should be taken on the column B if the value in Column H is Group....or Projects This is why I needed to have the different names, so only the ones corresponding should appear in the combobox...


then create also names for column B. Use as names the 3 left characters:

Sub Test()
Dim strData As String
Dim varData As Variant
Dim i As Long

strData = "Project,Group,Support"
varData = Split(strData, ",")

For i = 0 To UBound(varData)
ActiveSheet.Names.Add Name:=varData(i), RefersTo:= _
"=OFFSET($H$1,MATCH(""" & varData(i) & _
""",$H$1:$H$1000,0)-1,,COUNTIF($H:$H,""" & varData(i) & """))"
ActiveSheet.Names.Add Name:=Left(varData(i), 3), RefersTo:= _
"=Offset(" & varData(i) & ",,-6)"
Next
End Sub

Then insert the values into the combobox with:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then UserForm1 _
.ComboBox8.RowSource = "Sheet1!Pro"
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional