Hi Nina,
I'm not exactly sure what you're trying to get, but I'll try & help anyway.
First of all, no, a userform is not the same thing as a combobox. A combobox is one of the controls you can put in a userform, or it can be planted directly on the worksheet. By the nature of your question, I'll assume you're not using a userform and your combobox is on the sheet itself.
If you just want the combobox to always be in the upper left corner of your screen, and you're using the freeze panes feature, you can simply move the combobox up into the frozen pane. (ie, above & to the left of the intersecting black "freeze panes" lines.) Now, no matter where you scroll to, the combobox should remain right where it is.
If however you want the combobox to float around the screen in relation to the selected cell(s) then you can use this in the Sheet code module. (Right click the tab for the sheet of interest, choose View code, copy and paste the routine of your choice into the sheet module - [the white area on the right]. Press AltQ to get back to your excel sheet.)
This first one is if you're using a combobox from the Forms toolbar...
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 3 Or Target.Row < 3 Then Exit Sub
With ActiveSheet.Shapes("Drop Down 1")
.Top = Target.Offset(-2).Top
.Left = Target.Offset(, -2).Left
End With
End Sub
This second one is if you're using an ActiveX combobox from the Control Toolbox toolbar...
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 3 Or Target.Row < 3 Then Exit Sub
With ActiveSheet.Shapes("ComboBox1")
.Top = Target.Offset(-2).Top
.Left = Target.Offset(, -2).Left
End With
End Sub
What this will do is, if you make a selection in any column to the right of Col. B and any row below Row 2, it will always keep the top left corner of your combobox 2 rows above and 2 columns to the left of the cell you've selected. It won't do anything if you select a cell in columns A or B or in rows 1 or 2.
(These were adapted from code provided by (I think) Tom Urtis a year or so ago for use with a commandbutton)
The last one here will keep the combobox in the upper left corner of your screen, no matter where you select, and without using freeze panes.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ScrollRw As Long
Dim ScrollCol As Integer
ScrollRw = ActiveWindow.ScrollRow
ScrollCol = ActiveWindow.ScrollColumn
With ActiveSheet.Shapes("ComboBox1")
.Top = Cells(ScrollRw, ScrollCol).Top
.Left = Cells(ScrollRw, ScrollCol).Left
End With
End Sub
Is one of these what you were looking for?
Dan