how to process a simple loop in WWW::Mechanize to be more efficient?

Generating links

  • Please help me. Im tring to create a macro which will create a link for me depending upon the values in Column A and Row 2. I have data in the below format. First Row is the header. Code UK DE FR ABC111 ABC222 ABC333 Im looking for something, when macro is run. It should check Column A value and create a link with the text "Link" in against Rows... Like Under "UK" it should generate a link http://www.ABC111UK.uk and and under "DE" it should be http://www.ABC111DE.de and under "FR" it should be http://www.ABC111FR.fr Then it should check for column A Row 3 and do the same thing.. This process should be in loop till we have data in it. Is it possible. Please help. Thanks &

  • Answer:

    this worked for me: Note that at the beginning it deletes any existing hyperlinks in the Activesheet. This is for convenience. You can remove those lines if your don't need them. Sub AddHyperlinks() Dim hlink As Hyperlink Dim r As Range Dim cell As Range Dim i As Long ' clear existing hyperlinks For Each hlink In ActiveSheet.Hyperlinks hlink.Delete Next ' now add new hyperlinks Set r = Range("A2", Cells(Rows.Count, 1).End(xlUp)) For Each cell In r For i = 1 To 3 ActiveSheet.Hyperlinks.Add Anchor:=Cells(cell.Row, i + 1), Address:= _ "http://www." & cell.Text & Cells(1, i + 1) & "." & Cells(1, i + 1) Next i Next cell End Sub

Miningco.com Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.