+ Reply to Thread
Results 1 to 11 of 11

conditioning formatting?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2006
    Posts
    17

    conditioning formatting?

    Hi there!

    I have a question about conditioning formatting that I hope you're able to help.

    I wanted to set a range of cells to automatically create a hyperlink based on the data typed into it. for example, if I type '20300' into cell A1, I would like the display text to change from '20300' to US_00020300 and have it hyperlink to 'http://scr.blahblahblah.com/CHRDetails.pl?CHRID=US_00020300'.

    Is this doable? Please help.
    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Try this. Right-click on the sheet tab, select View Code, and copy this code:
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
        Dim Rng As Range
        Dim strHyp As String
        
        Set Rng = Range("A1:A100")
        strHyp = "http://scr.blahblahblah.com/CHRDetails.pl?CHRID="
        
        If Not Intersect(Target, Rng) Is Nothing Then
            
            If Not IsEmpty(Target) Then
                Application.EnableEvents = False
                Target = "US_000" & Target
                ActiveSheet.Hyperlinks.Add Target, strHyp & Target
                Application.EnableEvents = True
            End If
            
        End If
        
    End Sub
    You may want to change the above noted range (this is set so that it will only create a hyperlink if it is in range A1:A100).

    You will also, obviously, need to change the web address if it is not accurate.

    HTH

    Jason

  3. #3
    Registered User
    Join Date
    10-23-2006
    Posts
    17
    Hi Jason,

    Thanks for your prompt reply. Ok. I've cut and pasted it in, made the few necessary corrections then closed and returned to excel. Should I compile it or something because nothing is happening when I typed '22702'.


    thanks.

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    In which cell did you type the number?

  5. #5
    Registered User
    Join Date
    10-23-2006
    Posts
    17
    Hi Jason,

    I typed it in A1, A4...it returned just the number I typed it.
    Oh wait.....I cut and paste and didn't see the very first line till now! hold on....
    ok. that worked. THANKS!!!!

    This is the best site ever! I've posted here just once before and have gotten very prompt and accurate replies. Thanks for your assistance!

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    LOL Glad it worked for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1