View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Lluis Escude Lluis Escude is offline
external usenet poster
 
Posts: 6
Default From cell/combo to combo/cell

I finally have the code up and running (Sheet1 is protected so that only a
few unlocked cells can be selected):
========================================
In a module:
------------------------------------------------------------------------
Global oldtarget As Range
========================================
In ThisWorkbook:
------------------------------------------------------------------------
Private Sub Workbook_Open()
Range(ThisWorkbook.Names("StartCell")).Select
Set oldtarget = Range(ThisWorkbook.Names("StartCell"))
With ThisWorkbook.Sheets("Sheet1")
.EnableSelection = xlUnlockedCells
.Protect
End With
End Sub
========================================
In Sheet1:
------------------------------------------------------------------------
Private Sub ComboBox1_Click()
Application.Range("NextCell").Select
End Sub
------------------------------------------------------------------------
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyReturn Then Application.Range("NextCell").Select
End Sub
------------------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect
If oldtarget.Address = Range(ThisWorkbook.Names("StartCell")).Address
Then ComboBox1.Activate
Set oldtarget = Target
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
========================================