Exceeding Max Char Limit in Excel

后端 未结 11 1637
名媛妹妹
名媛妹妹 2020-12-10 06:51

How do I use more than 255 characters in Excel\'s CONCATENATE function? I am actually also using the CONCATENATE function within the HYPERLINK function in EXCEL. An example

相关标签:
11条回答
  • 2020-12-10 07:25

    You can create a hyperlink in Microsoft Word, and then copy it over to Excel. For some reason, those hyperlink elements are not limited by the 255 character limit, but you won't be able to use the HYPERLINK() function.

    Source

    0 讨论(0)
  • 2020-12-10 07:27

    The Hyperlink function has a hard limit that can't be overstaped. I had a similar problem and I simply imported the Excel sheet into Open Office Calc and voila - everything worked instantly and the hyperlink that was to long previously can be now as long as I wanted it to be.

    0 讨论(0)
  • 2020-12-10 07:28

    UPDATE: Because of Karls comment I revisited my answer an found out, that Excel 2007 does not seem to allow User Defined Functions to set hyperlinks anymore (quite sensibly, see my own comment in the code). So the original code (below the line) does not work in more recent versions of Excel (I haven't tested Excel 2010 but I assume the result is the same). For historical reasons I do not delete the old code (an editor might think otherwise -- feel free to edit/ delete accordingly).

    So what remains is to set long hyperlinks programatically, e.g.

    Sub insertVeryLongHyperlink()
    
        Dim curCell As Range
        Dim longHyperlink As String
    
        Set curCell = Range("A1")   ' or use any cell-reference
        longHyperlink = "http://www.veryLongURL.com/abcde"  ' Or a Cell reference like [C1]
    
        curCell.Hyperlinks.Add Anchor:=curCell, _
                        Address:=longHyperlink, _
                        SubAddress:="", _
                        ScreenTip:=" - Click here to follow the hyperlink", _
                        TextToDisplay:="Long Hyperlink"
    
    End Sub
    

    What follows does not work in Excel 2010 anymore; see my comment above

    The "copy the hyperlink from Word and paste into Excel" got me thinking. So obviously the limit is both in the built-in HYPERLINK-function and in the dialog-window 'edit hyperlink'. On the other hand it should be -- and actually is -- possible to set longer hyperlinks via VBA.

    This code does not work in Excel 2010 anymore

    Function myHyperlink(cell As Range, _
                            hyperlinkAddress As String, _
                            Optional TextToDisplay As Variant, _
                            Optional ScreenTip As Variant)
    
        ' Inserts a Hyperlink
        '   at the position     cell (this should be the position where the UDF is used,
        '                       since the return value of the UDF is = TextToDisplay)
        '   with the            hyperlinkAddress
        '   optional            TextToDisplay
        '   optional            ScreenTip
    
        ' #######################################
        ' Warning Warning Warning Warning Warning
        ' #######################################
    
        ' 1) Since it is really bad practice to have a function perform procedural
        '    tasks, you should not do this.
        ' 2) You have no garantee, the link is updated when the value hyperlinkAddress changes
    
        ' USE AT YOUR ONE RISK AND ONLY IN CASE OF EMERGENCIES :-)
    
    
        ' If more than one cell is selected as target range,
        ' use the top left cell
        Set cell = cell.Resize(1, 1)
    
        If IsMissing(TextToDisplay) Then
            TextToDisplay = hyperlinkAddress
        End If
    
        If IsMissing(ScreenTip) Then
            ScreenTip = hyperlinkAddress & " - Click here to follow the hyperlink"
        End If
    
        cell.Hyperlinks.Add Anchor:=ActiveCell, _
                            Address:=hyperlinkAddress, _
                            SubAddress:="", _
                            ScreenTip:=ScreenTip, _
                            TextToDisplay:=TextToDisplay
    
        ' There doesn't seem to be another way to set TextToDisplay
        myHyperlink = TextToDisplay
    
    End Function
    

    Use as a normal Excel-function, but be sure to add the current cell as first parameter (i.e. the following formula is inserted in cell A1)

    =myHyperlink(A1,B1)
    =myHyperlink(A1,B1,"TextToDisplay", "ScreenTip")
    

    You can neither pull the formula down nor copy it to another cell. If you do that you have to let the formula be recalculated (neither ALT-CTRL-F9 nor ALT-CTRL-SHIFT-F9 as force recalculate seem to work) so go into each cell, press F2 to activate it and finish with Return.

    I hope I am not helping you to screw up too many Excel-Workbooks.

    It is probably safer to write an VBA that is explicitly started that iterates through a list and writes to hyperlinks. That way they can reused and there are no functions.

    Regards Andreas

    0 讨论(0)
  • 2020-12-10 07:28

    Assuming you do not have very many hyperlink URLs >255 characters, just use the Link function. The link function is available from the right-click menu. No need to go to Word or any other MSOffice application. I know this works as I have a URL that is 281 characters long and that one works. I only have two very long URLs in my sheet so when/if they need updating I am making a note that they must be done in the target cell vs. on my sheet of hyperlink addresses.

    0 讨论(0)
  • 2020-12-10 07:31

    Instead of writing

    =CONCATENATE("Toto";"Tata")
    

    Put Toto in cell Z1 (for exemple) and Tata in cell Z2 and write

    =CONCATENATE(Z1;Z2)
    
    0 讨论(0)
  • 2020-12-10 07:34

    Dunno if my answer is still useful but I had the same issue couple of days ago, the best way and proved way to do a workable hyperlink that exceeds a 255 char limit is to first split it, with CONCATENATE(), and use the cell with CONCATENATE() function in VBA.

    For me it looks like:

    A1 = LinkPart1
    A2 = LinkPart2
    A3 = LinkPart3
    
    A5 = CONCATENATE( A1; A2; A3 )
    

    VBA Code you need to link with A5:

    Sub insertVeryLongHyperlink()
    
        Dim curCell As Range
        Dim longHyperlink As String
    
        Set curCell = Range("A7")   ' or use any cell-reference
        longHyperlink = [A5]
    
        curCell.Hyperlinks.Add Anchor:=curCell, _
                        Address:=longHyperlink, _
                        SubAddress:="", _
                        ScreenTip:=" - Click here to follow the hyperlink", _
                        TextToDisplay:="Click Here"
    
        End Sub
    
    0 讨论(0)
提交回复
热议问题