Hi
I have this code to copy data from listbox to sheet
bu I need adapting by copy after row6 and before total row and if I have rows in listbox more than empty rows inside the sheet then should insert new rows with the same borders ,if I have rows in listbox less than empty rows inside the sheet then should delete empty rows
here is the structure inside sheet
when fill listbox
the result should be
I have this code to copy data from listbox to sheet
VBA Code:
Private Sub cmdSend_Click()
With Me.ListBox1
If .ListCount > 0 Then
Sheets("SL").[a7].Resize(.ListCount, .ColumnCount) = .List
End If
End With
End Sub
here is the structure inside sheet
Sample.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
6 | ITEM | ID | QTY | UNIT PRICE | TOTAL | ||
7 | |||||||
8 | |||||||
9 | |||||||
10 | TOTAL | .00 | |||||
SL |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E10 | E10 | =SUM(E7:E9) |
when fill listbox
the result should be
Sample.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
6 | ITEM | ID | QTY | UNIT PRICE | TOTAL | ||
7 | 1 | ABSS-100 | 10 | 10.00 | 100.00 | ||
8 | 2 | *** TYYY 2000 | 12 | 22.00 | 264.00 | ||
9 | 3 | ASDE9900/1200 | 2 | 22.00 | 44.00 | ||
10 | 4 | XDD*7777 | 2 | 12.00 | 24.00 | ||
11 | TOTAL | 432.00 | |||||
SL |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E11 | E11 | =SUM(E7:E10) |