Andrew, it works perfectly - as long as I did not press ENTER in COL E. When I combined your code with this:
Code:
Private Sub ComboBox1_Change()
With ComboBox1
.TopLeftCell.EntireRow.Cells(1, 1).Value = .Column(0)
.TopLeftCell.EntireRow.Cells(1, 2).Value = .Column(1)
End With
End Sub
Private Sub ComboBox1_Click()
ActiveCell.Offset(0, 2) = Date
ActiveCell.Offset(0, 3) = "Autodeb"
ActiveCell.Offset(0, 4).Activate
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 Then
Application.MoveAfterReturn = True
ActiveCell.Offset(rowOffset:=-1, ColumnOffset:=-4).Activate
Application.SendKeys ("{ENTER}")
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Cancel = True
Set cboTemp = ws.OLEObjects("ComboBox1")
On Error Resume Next
'If Target.Cells.Count = 1 Then
' If Not (Target.Validation.Value) Then
' Application.EnableEvents = False
' With Range("ALL")
' With .Offset(.Rows.Count, 0).Range("A1")
' .Value = Target.Value
' .Offset(0, 1).Value = Application.InputBox("Corresponding value")
' End With
' End With
' Application.EnableEvents = True
' End If
'End If
If Target.Column = 1 Then
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 3
.ListFillRange = ws.Range("ALL").Address
.LinkedCell = Target.Address
End With
cboTemp.Activate
ComboBox1.DropDown
Else
With cboTemp
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
End If
End Sub
pressing the ENTER key in col E to return to the row below in col A and make the combo box and drop down list again visible, I get an error dialog box that says,
Run time error 381
"Could not get the Column property. Invalid property array index",
and line
Code:
.TopLeftCell.EntireRow.Cells(1, 1).Value = .Column(0)
is highlighted in yellow. Is that line interfering with something in the rest of this code?
Under normal circumstances, without your new code, the code above allows a user to choose a value from a two column drop down list box, put the first value in col A, put the date in col C, the word "Autodeb" in col D and move to col E, waiting for the user to enter a value. When a value is entered and ENTER is pressed, the active cell moves one row below in col A and the drop down list drops down waiting for the user to enter another value. That portion works perfectly also. I just wanted to incorporate adding the 2nd cols value of the drop down list in col B.
Thanks very much for your help. I hope I have not overburdened you with too much info.
chazrab
CR