Hello...
I have a list that when the cell in column U has "charge" in it, a row will be inserted below it, and column G will be changed to "Z001" and column J will be changed with the one from column R of the previous row (the total qty).
I found these lines of code in the internet.
With these lines, I can insert the row below and copy the previous row, but I don't know how to:
1. Paste it on the row that I just created.
2. Change column J with the value from column R of the previous row (the total qty).
Please help.....
Sub insertrow()
Dim i As Integer
Dim j As Integer
For i = 1 To 1000
j = InStr(1, Cells(i, 21), "charge", vbTextCompare)
If j = 1 Then
Cells(i + 1, 1).EntireRow.Insert
Cells(i, 1).EntireRow.Copy
Cells(i + 1, 7).Value = "Z001"
i = i + 2
Else
End If
Next i
End Sub
I have a list that when the cell in column U has "charge" in it, a row will be inserted below it, and column G will be changed to "Z001" and column J will be changed with the one from column R of the previous row (the total qty).
I found these lines of code in the internet.
With these lines, I can insert the row below and copy the previous row, but I don't know how to:
1. Paste it on the row that I just created.
2. Change column J with the value from column R of the previous row (the total qty).
Please help.....
Sub insertrow()
Dim i As Integer
Dim j As Integer
For i = 1 To 1000
j = InStr(1, Cells(i, 21), "charge", vbTextCompare)
If j = 1 Then
Cells(i + 1, 1).EntireRow.Insert
Cells(i, 1).EntireRow.Copy
Cells(i + 1, 7).Value = "Z001"
i = i + 2
Else
End If
Next i
End Sub
FPC test.xlsx | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | |||
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ||
2 | Date | No. | Customer code | Date | Delivery date | Note | Item no. | Customer no. | Warehouse code | Qty | Delivery code | Delivery company code | PIC | Memo to be printed 1 | Memo to be printed 2 | Order to warehouse | First/end of line | Total qty | Need to charge | customer's rows | Additional charge | ||
3 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH93 | GY331 | 4 | 2 | FPC01859 | 3 | No.GY331/No.5929 | №:4075886 | Attach delivery memo | 1 | 2 | Yes | 1 | charge | ||||
4 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH73 | GY332 | 6 | 5 | FPC01878 | No.GY332-769 | /No.FUP64-Q47/№:00839820-86 | Attach delivery memo | 1 | 12 | Yes | 3 | ||||||
5 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH53 | GY332 | 6 | 2 | FPC01878 | No.GY332-769 | /No.FUP64-Q47/№:00839820-86 | Attach delivery memo | 0 | 12 | Yes | 3 | ||||||
6 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH98 | GY769 | 6 | 5 | FPC01878 | No.GY332-769 | /No.FUP64-Q47/№:00839820-86 | Attach delivery memo | 2 | 12 | Yes | 3 | ||||||
7 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH53 | GX505 | 5 | 1 | FPC01923 | No.GX505/No.ア5894 | №:839653 | Attach delivery memo | 1 | 2 | Yes | 2 | ||||||
8 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH73 | GX505 | 5 | 1 | FPC01923 | No.GX505/No.ア5894 | №:839653 | Attach delivery memo | 2 | 2 | Yes | 2 | charge | |||||
9 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | GH43 | ケ5956 | 4 | 3 | FPC01A88 | No.5956/No.1844604 | Attach delivery memo | 1 | 3 | Yes | 1 | |||||||
10 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GH93 | GY651 | 4 | 5 | FPC01A93 | No.GY651/No.5107168 | Attach delivery memo | 1 | 5 | Yes | 1 | |||||||
11 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | KZ16 | GY554 | 6 | 1 | FPC01B02 | 1 | No.GY554/No.248979 | Attach delivery memo | 1 | 1 | Yes | 1 | charge | |||||
12 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | GH23 | ケ5690 | 6 | 1 | FPC01B21 | 1 | No.5690/No. | Attach delivery memo | 1 | 1 | Yes | 1 | charge | |||||
13 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | BM93 | GY793 | 6 | 1 | FPC01B36 | 1 | No.GY793/No.5468 | Attach delivery memo | 1 | 1 | Yes | 1 | charge | |||||
14 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | GL48 | ケ5674 | 4 | 6 | FPC01B43 | No.5674/No. | Attach delivery memo | 1 | 8 | Yes | 2 | |||||||
15 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | BM73 | ケ5674 | 4 | 2 | FPC01B43 | No.5674/No. | Attach delivery memo | 2 | 8 | Yes | 2 | |||||||
16 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | BM73 | GY791 | 6 | 2 | FPC01B55 | No.GY791/No.5467 | Attach delivery memo | 1 | 3 | Yes | 2 | |||||||
17 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | BM93 | GY791 | 6 | 1 | FPC01B55 | No.GY791/No.5467 | Attach delivery memo | 2 | 3 | Yes | 2 | |||||||
18 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/18 | BM73 | GY792 | 6 | 2 | FPC01B87 | No.GY792/No.5469 | Attach delivery memo | 1 | 2 | Yes | 1 | charge | ||||||
19 | 2024/4/16 | 0 | FPC01000 | 2024/4/16 | 2024/4/17 | JR13 | ケ5914 | 4 | 2 | FPC01C01 | 3 | No.5914/No. | Attach delivery memo | 1 | 2 | Yes | 1 | charge | |||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
Q3:Q19 | Q3 | =IF(K3="","",IF(K3<>K2,1,IF(K3<>K4,2,0))) |
R3:R19 | R3 | =IF(K3="","",SUMIF(K:K,K3,J:J)) |
T3:T19 | T3 | =IF(K3="","",COUNTIF(K:K,K3)) |
U3:U19 | U3 | =IF(AND(R3<3,S3="yes",T3=1),"charge",IF(AND(R3<3,S3="Yes",T3>1,Q3=2),"charge","")) |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
N3:N19 | Expression | =LENB(N3)>32 | text | NO |