I'am writting a small macro for opening links in browsers tab. Every 10th link is opened in new window. Can you tell me why variable index is not changing its value?
Sub OpenHyperLinks()
Dim xHyperlink As Hyperlink
Dim WorkRng As Range
Dim MaxTabs As Integer
MaxTabs = 10
Static index As Integer
index = 0
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each xHyperlink In WorkRng.Hyperlinks
If index Mod MaxTabs = 0 Then
xHyperlink.Follow NewWindow:=True
Else
xHyperlink.Follow NewWindow:=False
End If
Inc (index)
Next
End Sub
And incrementation function:
Function Inc(ByRef i As Integer)
i = i + 1
End Function
Thanks fo help :)