|
Sub 水费开单()
' https://club.excelhome.net/threa ... tml?_dsign=d73b2d5b
' 2024-8-27
'
Sheet1.Activate
xm = Sheet1.Cells(6, 1).Value
yf = Sheet1.Cells(6, 2).Value
sbds = Sheet1.Cells(6, 3).Value
foun = False
x2 = 5
Do While Not (IsEmpty(Sheet2.Cells(x2, 2).Value))
If Sheet2.Cells(x2, 2).Value = xm Then
foun = True
Sheet2.Cells(x2, yf * 3 + 1).Value = sbds
Sheet2.Cells(x2, yf * 3 + 2).Value = sbds - Sheet2.Cells(x2, yf * 3 - 2).Value
Sheet2.Cells(x2, yf * 3 + 3).Value = Sheet2.Cells(x2, yf * 3 + 2).Value * Sheet1.Cells(3, 2).Value
Sheet1.Cells(6, 4).Value = Sheet2.Cells(x2, yf * 3 - 2).Value
Sheet1.Cells(6, 5).Value = sbds - Sheet2.Cells(x2, yf * 3 - 2).Value
Sheet1.Cells(6, 6).Value = Sheet1.Cells(6, 5).Value * Sheet1.Cells(3, 2).Value
End If
x2 = x2 + 1
Loop
If foun = False Then
MsgBox "该用户未找到,请仔细核对姓名输入是否有误!!!"
Else
ActiveWindow.SelectedSheets.PrintPreview ' 先预览,再决定是否打印
End If
End Sub
|
|