Hi all,
Looking for some help on a loop. It's my first attempt at using one of these...so not surprising I am having difficulties.
I have a userform to record sick days, annual leave and so on. When the user clicks the submit button - the data in the form is written to the next free line. Pretty simple.
I am trying to add functionality so that the user can add whole blocks of time at once - for instance, two weeks of annual leave. this function would write 10 lines of data (one for each working day) and avoids the user having to change the data and press submit 10 times.
To keep it simple - I'm working with two combo boxes and just numbers (1-10), not dates. I will deal with the 'weekday' issue after.
Below is a cut back version of the code I'm using...can anyone please help?The code simply enters the first number - but does not seem to loop.
Dim MyNumber As Variant
MyNumber = Me.cboDate.Value
Do Until MyNumber > Me.cboEndDate.Value
Sheets("Data").Select
Range("A1").Select
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
nextR = Lastrow + 1
newR = "A" & nextR
Range(newR).Select
ActiveCell.Value = MyNumber
MyNumber= MyNumber + 1
If MyNumber > Me.cboEndDate.Value Then Exit Do
Loop
Thanks all
Robert
Bookmarks