View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Linking Comboboxes

If you only have one ticket number per date, you don't need the second item
to be a combobox. It should be a textbox

Private Sub combobox1_Click()
Dim dt as Long
With Userform1
if .Combobox1.ListIndex = -1 then exit sub
.Combobox2.RowSource = ""
.Combobox2.clear
dt = clng(cdate(.Combobox1.Value))
for each cell in Worksheets("Data").Range("A1:A200")
if cell.Value2 = dt then
Textbox2.Value = cell.offset(0,1).Text
end if
Next
End With
End Sub

there are a lot of ways you could approach this. Here is one way.

Private Sub ScrollBar1_Change()
Dim rng As Range, Rng1 As Range
Dim lRow As Long, Rng2 As Range

With ActiveSheet
Set rng = .Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
End With
ScrollBar1.Max = rng(rng.Rows.Count).Row
ScrollBar1.Min = 1

Set Rng1 = rng(ScrollBar1.Value)
Set Rng2 = ActiveWindow.VisibleRange.EntireRow
If Intersect(Rng1, ActiveWindow.VisibleRange.EntireRow) _
Is Nothing Then
lRow = Rng1.Row - Rng2.Rows.Count / 2
If lRow < 1 Then lRow = 1
ActiveWindow.ScrollRow = lRow
End If

End Sub

--
Regards,
Tom Ogilvy


"Oreg " wrote in message
...
Hi Tom,

Can't thank you enough. One thing I would like to change if possible.
When I click on combobox1 to get a date, I have to also click on
combobox2 for the related ticket number to populate. Any way to auto
poulate the ticket field? Also, If not to much trouble, would you know
a good place to start to get info on creating the scroll bar you
discussed earlier??

Thanks in advance


---
Message posted from http://www.ExcelForum.com/