Forum Discussion

Niels Tybjerg's avatar
Niels Tybjerg
Copper Contributor
May 06, 2017
Solved

Recreating a Twitter Search URL in Excel

Hi experts!   I'm an Excel NOOB and have hit a brick wall here - hope somebody can help:   I have a list in Excel with people on Twitter who are important to my company. I have all kinds of data ...
  • SergeiBaklan's avatar
    May 07, 2017

    Hi Niels,

     

    The most complex part of your task is to combine <from> part of the search string - we have to combine Twitter handle column in one string based on criteria are columns filtered or not.

     

    Afraid the easiest way is to use VBA. I took one of samples found on Web https://www.mrexcel.com/forum/excel-questions/637445-concatenate-text-visible-cells.html

    (Press Alt+F11 to open VBA environmen, copy/paste function code in new module)

     

    Public Function ConcatenateVisible(rng As Variant, seperator As String)
        For Each cll In rng
            If cll.EntireRow.Hidden = False Then _
                ConcatenateVisible = ConcatenateVisible & cll.Value & seperator
        Next
        ConcatenateVisible = Left(ConcatenateVisible, Len(ConcatenateVisible) - Len(seperator))
    End Function

    On your table above function

    =ConcatenateVisible(C2:C5," OR from:")

    returns result like

    frankjensenkbh OR from:idaauken OR from:uffeelbek

    After that the all what we need is to combine site URL and query string on it, e.g.

    https://twitter.com/search?q=
    
    to combine with
    
    Radikale %23dkpol from:idaauken OR from:nielstybjerg OR from:loveyourleads

    All parts for that we have now, resulting string use in HYPERLINK function

    =HYPERLINK("https://twitter.com/search?q=" & F2 & " %23" & F3 & " from:"&ConcatenateVisible(C2:C5," OR from:"), "Search Twitter")

    which returns needed hyperlink.

     

    File is attached - it is in macro-enabled format

     

Resources