View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Miller Dave Miller is offline
external usenet poster
 
Posts: 72
Default Urgent help with input box & loop

Try something like this:

Sub InputBoxLoop()
Dim r, c As Range, _
sState As String, _
lQty, lMiles As Long

sState = Range("A1").Value
lQty = InputBox("Input Quantity for " & sState)
lMiles = InputBox("Input Miles for " & sState)

Set r = Range("A1:A" & Range("A65536").End(xlUp).Row)

For Each c In r
If Not c.Value Like sState Then
sState = c.Value
lQty = InputBox("Input Quantity for " & sState)
lMiles = InputBox("Input Miles for " & sState)
End If
c.Offset(0, 1).Value = lQty
c.Offset(0, 2).Value = lMiles
Next c
End Sub

Regards,
David Miller