|
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
If Sheet2.Cells(x2, yf * 3 - 2).Value = "" Then
Sheet2.Cells(x2, yf * 3 + 2).Value = 0
Sheet2.Cells(x2, yf * 3 + 3).Value = 0
MsgBox "上期读数空,请手工处理好上期水表读数,再来计算 !"
GoTo kk
Else
If sbds >= Sheet2.Cells(x2, yf * 3 - 2).Value Then
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
Else
MsgBox "你输入的 抄表读数,小于 上期抄表读数,请再仔细核对 !!!"
GoTo kk
End If
End If
End If
x2 = x2 + 1
Loop
If foun = False Then
MsgBox "该用户未找到,请仔细核对姓名输入是否有误!!!"
Else
ActiveWindow.SelectedSheets.PrintPreview ' 先预览,再决定是否打印
kk: End If
End Sub
|
|