PDA

View Full Version : Referencing Named Ranges in UserForms



cscribner
09-12-2005, 08:51 PM
I'm comingto grips with the fact that macs don't support the .rowsource property. I have this lovely dynamic range that I want to put into a userform combobox, and it looks like I have to resort to an AddItem process. But I seem to be encountering a larger problem. I don't seem to be able to select specific sheets or cells at all from my userform. Is that really the case?

Here's the code I'm trying to use:



Private Sub UserForm_Initialize()
Sheets("Sheet1").Select
Range("TestListHeader").Select
Selection.End(xlDown).Select
Dim i As Integer
i = ActiveCell.Row
MsgBox ("The last row number in this list is: " & i)
End Sub


Obviously, I'm starting down the path of finding out how many items (rows) I need to add so I can run a neat little additem loop. But I'm getting errors on the very first row, where it's trynig to select the sheet, or the named cell.

How do you reference cells from VBA on a mac?

BlueCactus
09-12-2005, 11:00 PM
That's a little strange. It really ought to work, although you might want to change i to type Long to avoid overflow errors if your list is really long. On my machine it seems to always select the last row of the spreadsheet - not sure if this is the intention. But regardless, there should be no problems selecting specific sheets or cells (from code).

What error does it give you?

cscribner
09-13-2005, 03:28 AM
Thanks! I dont' know what was wrong, but after I restarted, Excel ran it perfectly. what a relief!