abdo meghari
Well-known Member
- Joined
- Aug 3, 2021
- Messages
- 612
- Office Version
- 2019
Hello
I have this code to copy to the bottom when run the form to sheet
and the formatting in sheet will be like this
when try copy data from form to sheet I want copy name from combobox1 and put under header in column D so the result will be
should be
and if I select another name then should copy the same formatting as in original sheet based how many rows need it and leave two empty rows as break .
example
should be
I hope to find solve for this subject.
EDITED: subject should copy from listbox to sheet, not from listbox to listbox as show in topic,sorry!
thanks
I have this code to copy to the bottom when run the form to sheet
VBA Code:
Private Sub CommandButton2_Click()
Dim rngNext As Range
Dim i As Long
Dim col As Long
Set rngNext = Worksheets("NAMES").Range("A" & Rows.Count).End(xlUp).Offset(1)
For i = 1 To ListBox1.ListCount - 1
For col = 0 To ListBox1.ColumnCount - 1
rngNext.Offset(, col).Value = ListBox1.List(i, col)
Next col
Set rngNext = rngNext.Offset(1)
Next i
End Sub
DECREASE.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | NAMES | ||||||||
2 | |||||||||
3 | ITEM | DATE | INV.NO | CASE | DEBIT | CREDIT | BALANCE | ||
4 | |||||||||
5 | |||||||||
6 | |||||||||
7 | |||||||||
8 | |||||||||
9 | |||||||||
10 | |||||||||
11 | |||||||||
12 | |||||||||
13 | |||||||||
14 | |||||||||
15 | |||||||||
16 | |||||||||
17 | |||||||||
18 | |||||||||
NAMES |
when try copy data from form to sheet I want copy name from combobox1 and put under header in column D so the result will be
should be
DECREASE.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | NAMES | ||||||||
2 | CCF-1000 | ||||||||
3 | ITEM | DATE | INV.NO | CASE | DEBIT | CREDIT | BALANCE | ||
4 | 1 | 30/06/2023 | - | -500 | -500 | ||||
5 | 2 | 15/07/2023 | RVCH20000 | 30,000.00 | - | 29,500.00 | |||
6 | 3 | 15/07/2023 | RVCH20002 | 10,000.00 | - | 39,500.00 | |||
7 | 4 | 15/09/2023 | BSTR_23448 | OUTSANDING | - | 2,300.00 | 37,200.00 | ||
8 | 5 | 15/09/2023 | BSTR_23449 | OUTSANDING | - | 1,920.00 | 35,280.00 | ||
9 | 6 | 15/09/2023 | BSTR_23450 | PAID | 50,400.00 | - | 85,680.00 | ||
10 | 7 | 15/09/2023 | BSJ_23444 | OUTSANDING | 1,720.00 | - | 87,400.00 | ||
11 | 8 | 15/09/2023 | BSJ_23446 | PAID | - | 4,900.00 | 82,500.00 | ||
12 | 9 | 15/09/2023 | VSTR_23444 | PAID | - | 500 | 82,000.00 | ||
13 | 10 | 15/09/2023 | VSTR_23446 | OUTSANDING | 3,600.00 | - | 85,600.00 | ||
14 | 11 | 15/09/2023 | RSS_23222 | OUTSANDING | - | 860 | 84,740.00 | ||
15 | 12 | 15/09/2023 | VCH20005 | - | 15,000.00 | 69,740.00 | |||
16 | 13 | 16/09/2023 | VSTR_23449 | PAID | - | 3,760.00 | 65,980.00 | ||
17 | 14 | 16/09/2023 | RSS_23224 | PAID | 2,950.00 | - | 68,930.00 | ||
18 | SUM | 98,670.00 | 28,740.00 | 69,930.00 | |||||
NAMES |
and if I select another name then should copy the same formatting as in original sheet based how many rows need it and leave two empty rows as break .
example
should be
DECREASE.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | NAMES | ||||||||
2 | CCF-1000 | ||||||||
3 | ITEM | DATE | INV.NO | CASE | DEBIT | CREDIT | BALANCE | ||
4 | 1 | 30/06/2023 | - | -500 | -500 | ||||
5 | 2 | 15/07/2023 | RVCH20000 | 30,000.00 | - | 29,500.00 | |||
6 | 3 | 15/07/2023 | RVCH20002 | 10,000.00 | - | 39,500.00 | |||
7 | 4 | 15/09/2023 | BSTR_23448 | OUTSANDING | - | 2,300.00 | 37,200.00 | ||
8 | 5 | 15/09/2023 | BSTR_23449 | OUTSANDING | - | 1,920.00 | 35,280.00 | ||
9 | 6 | 15/09/2023 | BSTR_23450 | PAID | 50,400.00 | - | 85,680.00 | ||
10 | 7 | 15/09/2023 | BSJ_23444 | OUTSANDING | 1,720.00 | - | 87,400.00 | ||
11 | 8 | 15/09/2023 | BSJ_23446 | PAID | - | 4,900.00 | 82,500.00 | ||
12 | 9 | 15/09/2023 | VSTR_23444 | PAID | - | 500 | 82,000.00 | ||
13 | 10 | 15/09/2023 | VSTR_23446 | OUTSANDING | 3,600.00 | - | 85,600.00 | ||
14 | 11 | 15/09/2023 | RSS_23222 | OUTSANDING | - | 860 | 84,740.00 | ||
15 | 12 | 15/09/2023 | VCH20005 | - | 15,000.00 | 69,740.00 | |||
16 | 13 | 16/09/2023 | VSTR_23449 | PAID | - | 3,760.00 | 65,980.00 | ||
17 | 14 | 16/09/2023 | RSS_23224 | PAID | 2,950.00 | - | 68,930.00 | ||
18 | SUM | 98,670.00 | 28,740.00 | 69,930.00 | |||||
19 | |||||||||
20 | |||||||||
21 | NAMES | ||||||||
22 | CCF-1001 | ||||||||
23 | ITEM | DATE | INV.NO | CASE | DEBIT | CREDIT | BALANCE | ||
24 | 1 | 30/06/2023 | 2,000.00 | - | 2,000.00 | ||||
25 | 2 | 15/07/2023 | RVCH20001 | 25,000.00 | - | 27,000.00 | |||
26 | 3 | 15/09/2023 | VSTR_23445 | OUTSANDING | 1,000.00 | - | 28,000.00 | ||
27 | 4 | 16/09/2023 | BSTR_23452 | PAID | 7,200.00 | - | 35,200.00 | ||
28 | SUM | 35,200.00 | - | 35,200.00 | |||||
29 | |||||||||
NAMES |
I hope to find solve for this subject.
EDITED: subject should copy from listbox to sheet, not from listbox to listbox as show in topic,sorry!
thanks