13

Consider the following Excel sheet:

     A             B                       C
1 ASX:ANZ      ANZ:ASX       http://www.site.com/page?id=ANZ:ASX
2 DOW:1234     1234:DOW      http://www.site.com/page?id=1234:DOW
3 NASDAQ:EXP   EXP:NASDAQ    http://www.site.com/page?id=EXP:NASDAQ

I need a formula for the B and the C column. In the B column I need the values of the A column to be split on : and the two resulting parts to be reversed, see the three examples. In the C column, I need the result from B to be added to a (hardcopy) URL (http://www.site.com/page?id=) to form a link.

Who can help me out? Your help is greatly appreciated!

Pr0no
  • 3,910
  • 21
  • 74
  • 121

3 Answers3

26

Alright. I don't normally spoon feed answers but here you go.

In B:

=MID(A1, FIND(":", A1, 1)+1, LEN(A1) - FIND(":",A1,1)) & ":"&MID(A1,1,FIND(":",A1,1)-1)

In C:

=HYPERLINK("http://www.site.com/page?id="&B1)
ApplePie
  • 8,814
  • 5
  • 39
  • 60
6
=hyperlink("http://www.site.com/page?id="&B1) *english version *
Alan Waage
  • 603
  • 4
  • 12
-1

The loop looks something like his:

Dim row As Integer
Dim snumber As Variant
Dim TestCell As String
Dim lastcell As Integer

Sheets("data").Select


lastcell = Sheets("data").Cells(Rows.Count, "A").End(xlUp).row

For row = 1 To lastcell
    TestCell = "A" & row
    snumber = Range(TestCell).Value
    If snumber <> "" And snumber <> "0" Then
        Range(TestCell).Select
        ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
        "url goes here", TextToDisplay:=snumber
    End If
Next row
Jim
  • 1,056
  • 1
  • 13
  • 19