• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Runtime error 9, Subscript out of range

Kavish Sekhri

New Member
Hi, Can anyone please help me with setting the range for this?

Currently I am using the following VBA

Code:
Sub CreateSheetsFromAList()

Dim Country As String
Dim N As Long

Country = Sheets("Launch").Range("D3")
MsgBox "Opening Links for Country -  " & Country

N = Sheets(Summary).Cells(1, 1).End(xlDown).Row


If N = 1048576 Then
    MsgBox "No Data Present for the Country - " & Country
Else
    For Each link In Sheets(Country).Range("A1:A" & N)
        ActiveWorkbook.FollowHyperlink Address:=link
    Next link
End If

End Sub


Here the range is for Column A i.e. Range("A1:A" & N), however I want to change it to Row 2 from cell B2 to Z2.

Please check the image attached to get an idea of the range.

I want to execute all the web-links from B2 to Z2.

Thanks
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
 

Attachments

  • Sample.JPG
    Sample.JPG
    26.7 KB · Views: 11
Last edited by a moderator:
Can you please describe what your trying to do as your commentary doesn't really match the code that you have supplied
 
Can you please describe what your trying to do as your commentary doesn't really match the code that you have supplied

Hi Hui,

Can you help with a macro for the attached sheet "Source list new"?

Worksheet "Launch" has a drop-down of different countries which are mentioned in Column A of second worksheet "Summary" along with their respective web-links in Column B, C, D, and so on.

I want a VBA to open all the web-links pertaining to a country in drop-down on clicking the Launch button.

For example, on selecting Australia as a country in the drop-down in "Launch" worksheet, all web-links in B1, C1, D1, and E1 of "Summary" worksheet should open.

Thanks..
 

Attachments

  • Source list new.xlsm
    29.1 KB · Views: 1
Hi ,

See if this is OK.

Narayan

Hi Narayan,

First, Thanks a lot for helping me out with the code, it works perfect.

Can you please check this file as I have applied the same code on multiple worksheets in a single file.

It does work and open the respective web links but on every run it gives "Run-time error 5- Invalid Procedure call or argument" on "ActiveWorkbook.FollowHyperlink Address:=link".

Please check the attached file for reference.
 

Attachments

  • Source list (1).xlsm
    61.3 KB · Views: 1
Back
Top