Hi everyone....
I Have a userform with a listbox which is populated with row source property.
After selecting a row in the Userform, A delete Key should remove the selected Row in the list box and the corresponding worksheet cell values in the range "B4 to B14" and "E4 to E14"
and cells values below (If at all present) these should shift up...... and NOT the whole column.
I am so far able to delete only values from one column ie "B" and that too the whole column beyond "B14" shifts up, this should not happen as there is another table below this range.
Columns "C", "D" and "F" in the worksheet Range B4:F17 have formulas and are populated as per the values of Column "B" and "E".
Currently I am using this code.....
Please Help....
I Have a userform with a listbox which is populated with row source property.
After selecting a row in the Userform, A delete Key should remove the selected Row in the list box and the corresponding worksheet cell values in the range "B4 to B14" and "E4 to E14"
and cells values below (If at all present) these should shift up...... and NOT the whole column.
I am so far able to delete only values from one column ie "B" and that too the whole column beyond "B14" shifts up, this should not happen as there is another table below this range.
Columns "C", "D" and "F" in the worksheet Range B4:F17 have formulas and are populated as per the values of Column "B" and "E".
Currently I am using this code.....
Please Help....
VBA Code:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim i As Long
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) = True Then
Range("B" & i + 4).Delete Shift:=xlUp
End If
Next i
End Sub
Book1.xlsm | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | |||||||||||
2 | |||||||||||
3 | S.No. | BarCode | Item | Unit Price | Qty. | Total | |||||
4 | 2 | 8 | |||||||||
5 | 3 | 3 | |||||||||
6 | 2 | 5 | |||||||||
7 | 5 | 4 | |||||||||
8 | 5 | 3 | |||||||||
9 | 3 | 2 | |||||||||
10 | 2 | 1 | |||||||||
11 | 3 | 2 | |||||||||
12 | 8 | 9 | |||||||||
13 | 7 | 8 | |||||||||
14 | |||||||||||
15 | |||||||||||
16 | |||||||||||
17 | |||||||||||
18 | |||||||||||
19 | |||||||||||
20 | 58 | 2 | |||||||||
21 | 8 | 7 | |||||||||
22 | 7 | 8 | |||||||||
23 | 8 | 9 | |||||||||
24 | 9 | 7 | |||||||||
25 | 6 | 8 | |||||||||
26 | 1 | 5 | |||||||||
27 | 8 | 2 | |||||||||
28 | |||||||||||
29 | |||||||||||
30 | |||||||||||
31 | |||||||||||
Sheet1 |