Attribute VB_Name = "modReport"
Option Explicit

' 一键月报：把公式区当月值写成静态快照行（只追加，不覆盖）
Public Sub BuildMonthlyReport()
    Dim ws As Worksheet, wsP As Worksheet, r As Long
    On Error GoTo ErrH
    Set ws = Sh("月度报表")
    Set wsP = Sh("参数")
    r = 28
    Do While ws.Cells(r, 1).Value <> ""
        r = r + 1
        If r > 200 Then MsgBox "快照区已满，请归档历史行。": Exit Sub
    Loop
    ws.Cells(r, 1).Value = Format(wsP.Range("B2").Value, "yyyy-mm")
    ws.Cells(r, 2).Value = ws.Range("B2").Value    ' 新增线索
    ws.Cells(r, 3).Value = ws.Range("B4").Value    ' 转化率
    ws.Cells(r, 4).Value = ws.Range("B14").Value   ' 赢单率
    ws.Cells(r, 5).Value = ws.Range("B19").Value   ' 订单总额
    ws.Cells(r, 6).Value = ws.Range("B21").Value   ' 回款总额
    ws.Cells(r, 7).Value = ws.Range("B22").Value   ' 期末应收
    ws.Cells(r, 8).Value = ws.Range("B6").Value    ' 退回公海
    ws.Cells(r, 9).Value = ws.Range("B23").Value   ' 公海申领
    ws.Activate
    ws.Cells(r, 1).Select
    MsgBox "已写入 " & ws.Cells(r, 1).Value & " 月度快照（静态值，随参数区实时公式互为核对）。"
    Exit Sub
ErrH:
    Fail "一键月报"
End Sub
