'How to set SharePoint path using a string variable on sheet

Dim path as String
dim a as string
dim b as string

a = range("A4") // variable name in cell
b = range("A106") // variable of other name in cell

Workbooks.Open ("https://hmrc.sharepoint.com/teams/GRP044020483/Managers%20Checks/Stat%20Sheets/" & a &"/" & b & ".xlsx")

I think it should work something like this but I get an error message.

Thanks



Solution 1:[1]

You need to call the value in the range. try the below

Dim path as String
dim a as string
dim b as string

a = range("A4").Value ' variable name in cell
b = range("A106").Value ' variable of other name in cell

Workbooks.Open ("https://hmrc.sharepoint.com/teams/GRP044020483/Managers%20Checks/Stat%20Sheets/" & a &"/" & b & ".xlsx")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1