View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
apndas[_11_] apndas[_11_] is offline
external usenet poster
 
Posts: 1
Default userform multiselect listbox problem


Thanks Tom

in the interim i came up with this code which seems to work although
from a technical point of view is probably not the best solution. I
will test your code and see how it goes

'copy data to database


For lItem = 0 To lbManifestCurrent.ListCount - 1
If lbManifestCurrent.Selected(lItem) = True Then
With ws1
Dim lRow As Long
lRow = ws1.Range("a65536").End(xlUp).Row
For i = lRow To 11 Step -1
If Cells(i, 3).Value =
lbManifestCurrent.List(lItem) Then
Set rng = Worksheets("Freight Accrual History")
_
..Cells(Rows.Count, 1).End(xlUp)(2)
Rows(i).EntireRow.Copy rng
Cells(i, 7).Value = "x"
Exit For
End If

Next i
End With

lbManifestCurrent.Selected(lItem) = False
End If
Next

'delete rows transferred from current to history

For i = lRow To 11 Step -1
If Cells(i, 7).Value = "x" Then
Rows(i).EntireRow.Delete
End If
Next i

this way it was not altering my listbox until all of the selected
listbox items had been placed into history


--
apndas
------------------------------------------------------------------------
apndas's Profile: http://www.excelforum.com/member.php...o&userid=36137
View this thread: http://www.excelforum.com/showthread...hreadid=564054