我正在开展一个记录和查看加售的项目。 这一切都由MSforms控制。 每个月都有自己的表格,所有用户加售也都张贴。 我已经建立了计算来计算每个用户的月份加价,但我现在需要做的是计算每个用户的年初数据。 用户名将通过我构建的登录系统发布到变量中。 如果它有助于记录加售的工作表以“ups”开头。 在此先感谢您的帮助。
Public Sub btn_test_Click()
Dim var_nextline4 As Integer
Dim var_Allsheets As Variant
var_YupsN = 0
var_YpremR = 0
var_Yhups = 0
var_ytdRev = 0
Dim WS As Worksheet
Dim z As Variant
z = "a"
For Each WS In ThisWorkbook.Worksheets
' do something with worksheet WS
If Worksheets(WS).Cells(1, 1) = "Associate Name" Then
var_nextline4 = 2
'z = "a"
Do While z <> ""
z = Worksheets(WS).Cells(var_nextline4, 1)
If z <> var_associate Then
var_nextline4 = var_nextline4 + 1
Else
Me.lsb_upsell.AddItem Cells(var_nextline4, 5).Value
Select Case Worksheets(WS).Cells(var_nextline4, 10)
Case "CYS"
var_YpremR = Yvar_premR + Worksheets(WS).Cells(var_nextline4, 6).Value
Case "LDS"
var_YpremR = var_YpremR + Worksheets(WS).Cells(var_nextline4, 6).Value
Case "LVK"
var_YpremR = var_YpremR + Worksheets(WS).Cells(var_nextline4, 6).Value
Case "LVD"
var_YpremR = var_YpremR + Worksheets(WS).Cells(var_nextline4, 6).Value
Case "LVB"
var_YpremR = Yvar_YpremR + Worksheets(WS).Cells(var_nextline4, 6).Value
Case Else
End Select
If var_Yhups < Worksheets(WS).Cells(var_nextline4, 13).Value Then
var_Yhups = Worksheets(WS).Cells(var_nextline4, 13).Value
End If
var_ytdRev = var_ytdRev + Worksheets(WS).Cells(var_nextline4, 13).Value
var_Yforms = var_Yforms + 1
var_YupsN = var_YupsN + Worksheets(WS).Cells(var_nextline4, 6).Value
var_nextline4 = var_nextline4 + 1
End If
Loop
End If
Next WS
lbl_ytdUpsForms = var_Yforms
lbl_ytdUpsn = var_YupsN
lbl_ytdPrem = var_YpremR
lbl_ytdHups = "£" & var_Yhups
lbl_ytdRev = "£" & var_ytdRev
End Sub