1

I am using the code below to refresh a HFM worksheet and update two of the variables in the POV, Year and Period.

I need to replace the 'Mar' in "Period#Mar" with the contents of a cell on a separate worksheet (which is currently 'Mar', but will change each month).

I have tried to create a range object, but the HypSetPOV function requires a string, rather than a range. So I am not sure if I somehow need to convert my range into a string, or do something different.

The code without the range (which updates the period to 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

The code I tried with a range (which does not update the period at all):

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

Thanks in advance :)

  • cstr https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/type-conversion-functions – cyboashu Jul 29 '19 at 16:11
  • What is `HypSetPOV`? Also, you could use `REPLACE()`, no? – BruceWayne Jul 29 '19 at 16:16
  • @BruceWayne it's a function in Hyperion SmartView. Surprised there's no tag for hyperion smartview yet - the current smart view tag is Samsung-related. – BigBen Jul 29 '19 at 16:17

2 Answers2

1

You can do this:

X = HypSetPOV(SheetName, "Year#2019", _
              "Period#" & ActiveWorkbook.Sheets("Udatate").Range("D9").Value)
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
0

You could use REPLACE():

Sub HFM_Refresh()
Dim ws As Worksheet

Set ws = Worksheets("1 - PII PL Reporting Month")

ws.Visible = True

Dim replCell As Range, targetRng As Range
' replCell will be the cell you want to use
' to find the replacement.
Set replCell = ws.Range("A1")

' targetRng is the range of cells you want to
' replace `Period#Mar` with (or any other such
' string, like `Period#May`, etc.

Set targetRng = ws.Range("B1:B10")

Dim cel As Range
targetRng.Replace "Period#*", "Period#" & replCell.Value, xlPart

End Sub
BruceWayne
  • 22,923
  • 15
  • 65
  • 110