PDA

View Full Version : Solved: Loop Until Help



elasez
02-20-2013, 06:42 PM
What I have is a User form with a combobox and a textbox on it.

My combobox is useing a Rowsource which is located on sheet5 starting at cell a1.

When the user makes a selection from the Combobox i need excel to activate the cell which that selection is in.

My code is as follows and it breaks every time at "ActiveCell.Offset(0, 1).Select"

I have the code working elsewhere so i am confused why it wont work here.



Private Sub ComboBox1_Change()
Sheets("sheet5").Activate
Range("A1").Select

Do
If ActiveCell <> ComboBox1 Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until ActiveCell = ComboBox1

End Sub


Example of working code referenced above.


Private Sub addbtn_Click()
Sheets("sheet2").Activate
Range("A2").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True


any guidance would be appreciated.

(using excel 2010)


This code fixed it sorry about the unneeded post. =P




Private Sub ComboBox1_Click()
Sheets("sheet5").Activate
Range("A1").Select

Do
If ActiveCell <> ComboBox1 Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until ActiveCell = ComboBox1

End Sub