我有一个 XLS 可以检索动态生成的报告列表:
B | C | D | E | F | G | H | I | J
1 1 | Bob |Jones |bjones| rep 1|Sales Report | Desc.| X | fnGenerateSalesReport
2 1 | Bob |Jones |bjones| rep 2|Revenue Rep. | Desc.| _ | fnGenerateRevenueReport
3 1 | Bob |Jones |bjones| rep 3|Customer List| Desc.| _ | fnGenerateCustReport
4 1 | Bob |Jones |bjones| rep 4|Stock Report | Desc.| _ | fnGenerateStockReport
用户在他们希望生成的报告(第 I 列)旁边标记 X,然后按下“生成”按钮。如何根据用户选择运行相关功能。相关功能的名称(每个报告一个功能)列在报告列表的特定列 (Col J) 中(见下文)。
在这一debug.print
行,我希望它使用保存的动态值调用函数c.Offset(0, 1).Value
Dim ws As Worksheet, rng As Range, stRows As Long
Dim c As Range
Set ws = Sheets("AVAILABLE REPORTS")
Set rng = ws.Range("B12:B12")
Set rng = ws.Range(rng, rng.End(xlDown))
stRows = rng.Rows.Count
Set rng = ws.Range("I12:I12")
Set rng = ws.Range("I12:I" & 11 + stRows)
For Each c In rng.Cells
If c.Value = "X" Or c.Value = "x" Then
Debug.Print "> [" & c.Value & " (" & c.Offset(0, 1).Value & ")]"
End If
Next