CodePudding user response:
Have "idea", according to your idea to write code for bai,The "three decimal places", can set the cell formatting to show,
The "actual value" in the cell suggest or retain its original value, so at the time of "statistical", "error" will be reduced,
CodePudding user response:
Problem is to write don't come, small white a completely, now in the study, hope there is a example to learn and studyCodePudding user response:
Can directly use the formula...CodePudding user response:
Please call me lei feng!Open the macro dialog box, create a new name for the test macro, and then click edit, enter the following code:
Sub test ()
Sheet2. Cells (1, 1)="material name"
Sheet2. Cells (1, 2)="specifications"
Sheet2. Cells (1, 3)="unit", "
Sheet2. Cells (1, 4)="number"
Sheet2. Cells (1, 5)="settlement price
"Sheet2. Cells (1, 6)="corresponding amount
"
Dim As Integer I
I=2
While Sheet1. Cells (I, 1) & lt;> "
"Dim j As Integer
For j=1 To 7
If j & lt; 4 Then=
Sheet2. Cells (I, j)=Sheet1. Cells (I, j)
ElseIf j=7 Then
Sheet2. Cells (I, 5)=Sheet1. Cells (I, j)
End the If
Next
If Sheet1. Cells (I, 8) & gt; Then 116000
Sheet2. Cells (I, 4)=Fix (116000/Sheet2. Cells (I, 5) * 1000)/1000
Sheet2. Cells (I, 6)=Sheet2. Cells (I, 4) * Sheet2. Cells (I, 5)
The Else
Sheet2. Cells (I, 6)=Sheet1. Cells (I, 8)
End the If
I=I + 1
Wend
End Sub
Excel spreadsheet download address:
https://download.csdn.net/download/milaoshu1020/10763168
CodePudding user response:
You can take a look at this I tried theOption Explicit
Sub automatically generated receipt ()
Dim w As Worksheet
Dim w1 As Worksheet
Dim j As Integer
Dim As Integer I
Dim As Integer k
Dim x As Integer
Dim x1 As Double
Dim x2 As Double
K=2
Set w=Worksheets (" table ")
Sheets. The Add (before:=Sheets (" table ")). The Name="receipt"
The Set w1=Worksheets (" receipt ")
W1. Cells (1, 1)=w.C ells (1, 1)
W1. Cells (1, 2)=w.C ells (1, 2)
W1. Cells (1, 3)=w.C ells (1, 3)
W1. Cells (1, 4)=w.C ells (1, 4)
W1. Cells (1, 5)=w.C ells (1, 7)
W1. Cells (1, 6)=w.C ells (1, 8)
For j=2 To w.U sedRange. Rows. Count Step 1
X=Round (w.C ells (j, 8) 116000 +/0.5, 0)
If x & gt; 1 Then
For I=1 To Step 1 x - 1
X1=Round (116000/w.C ells (j, 7), 3) - 0.001
(x1 x2=Round * w.C ells (j, 7), 2)
W1. Cells (k, 1)=w.C ells (j, 1)
W1. Cells (k, 2)=w.C ells (j, 2)
W1. Cells (k, 3)=w.C ells (j, 3)
W1. Cells (k, 4)=x1
W1. Cells (k, 5)=w.C ells (j, 7)
W1. Cells (k, 6)=x2
K=k + 1
X=x - 1
If x=1 Then
W1. Cells (k, 1)=w.C ells (j, 1)
W1. Cells (k, 2)=w.C ells (j, 2)
W1. Cells (k, 3)=w.C ells (j, 3)
W1. Cells (k, 4)=w.C ells (j, 4) - (Round (116000/w.C ells (j, 7), 3) - 0.001) * (Round (w.C ells (j, 8) 116000 +/0.5, 0) - 1)
W1. Cells (k, 5)=w.C ells (j, 7)
W1. Cells (k, 6)=w.C ells (j, 8) - Round (x1 * w.C ells (j, 7), 2) * (Round (w.C ells (j, 8) 116000 +/0.5, 0) - 1)
K=k + 1
End the If
Next I
End the If
Next j
End Sub
CodePudding user response:
The original poster is missing, but also to dig the grave...