我正在使用下面的代码来刷新 HFM 工作表并更新 POV、Year 和 Period 中的两个变量。
我需要将“Period#Mar”中的“Mar”替换为单独工作表上的单元格内容(当前为“Mar”,但每个月都会更改)。
我试图创建一个范围对象,但 HypSetPOV 函数需要一个字符串,而不是一个范围。所以我不确定我是否需要以某种方式将我的范围转换为字符串,或者做一些不同的事情。
没有范围的代码(将期间更新为 Mar):
Sub HFM_Refresh()
Dim SheetName As String
Dim sts As Long
SheetName = "1 - PII PL Reporting Month"
ActiveWorkbook.Worksheets(SheetName).Visible = True
ActiveWorkbook.Worksheets(SheetName).Activate
ActiveWorkbook.Worksheets(SheetName).Range("A1").Activate
X = HypSetPOV(SheetName, "Year#2019", "Period#Mar")
sts = HypMenuVRefresh()
If sts <> 0 Then
MsgBox "Error - refresh not complete on worksheet " & SheetName
End If
End Sub
我尝试使用范围的代码(根本不更新期间):
Sub HFM_Refresh()
Dim SheetName As String
Dim sts As Long
Dim MonthMember As Range
SheetName = "1 - PII PL Reporting Month"
Set MonthMember = ActiveWorkbook.Worksheets("Update").Range("D9")
ActiveWorkbook.Worksheets(SheetName).Visible = True
ActiveWorkbook.Worksheets(SheetName).Activate
ActiveWorkbook.Worksheets(SheetName).Range("A1").Activate
X = HypSetPOV(SheetName, "Year#2019", "Period#MonthMember")
sts = HypMenuVRefresh()
If sts <> 0 Then
MsgBox "Error - refresh not complete on worksheet " & SheetName
End If
End Sub
提前致谢 :)