open worksheet on first unlocked cell

R

Ruth

Hi there

I have a form that opens automatically when the file is open. It has a
combo box with a list of the worksheets that when one is selected the
worksheet opens. I used the following code:

Private Sub ComboBox1_Change()
Sheets(ComboBox1.Text).Select
End Sub

Private Sub UserForm_Activate()
For Each Sheet In ActiveWorkbook.Sheets
ComboBox1.AddItem (Sheet.Name)
Next
End Sub

It works great-- but the active cell is just the last cell used. I want it
to open with the first unlocked cell active. Can this be done, if so, how?
 
J

John Bundy

Before your end sub select the cell
Activesheet.Cells(1,1).select
equalling cells(row,column) so the above selects cell A1
 
M

Mike H

Ruth,

I assume by 'Unlocked' you mean the 'Locked' checkmark has been removed with
Format|Cells - protection tab. If so try this

Private Sub ComboBox1_Change()
For Each c In Sheets(ComboBox1.Text).UsedRange
If c.Locked = False Then
Sheets(ComboBox1.Text).Range(c.Address).Select
Exit For
End If
Next
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top