Results 1 to 5 of 5

Custom INDEX function that can handle >255 characters

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Unhappy Custom INDEX function that can handle >255 characters

    Hi,

    I am trying to use the `Application.Index` function with an variant 2D Array which contains some elements having >255 characters of text. This results in Variant/Integer Type `Type Mismatch` error. I am also unable to use `Application.Transpose` because of hitting this >255 characters limit.

    Has anyone made any `Custom INDEX UDFunction` that can handle >255 characters of text to overcome this limit?

    e.g.
    Index Type MisMatch error.PNG


    The snippet code looks like this:

    
    ........
    ........
    For j = 1 to NoOfSlides
        A = (j - 1) * (nRw * 2) + 1
        B = IIf(A >= UBound(Arr, 1), UBound(Arr, 1), (A + (nRw * 2)) - 1)
        If B > UBound(Arr, 1) Then B = UBound(Arr, 1)
        ab_Rng = Evaluate("row(" & A & ":" & B & ")")
    
        TmpArr(j) = Application.Index(Arr, ab_Rng, Array(1, 2))     ' Type Mismatch Error
        With oPres
            Set oSlide = .slides("Slide0_ABC").Duplicate
            oSlide.moveto toPos:=.slides.Count
            With oSlide
            ....
            End With
            
            If getDimensions(TmpArr(j))<2 Then 
                TmpArr(j) = Application.Transpose(TransposeDim(TmpArr(j)) )    ' Error
            End If
            For y = LBound(TmpArr(j), 1) To UBound(TmpArr(j), 1)
            .....
            Next y
        End With
    Next j
    ........
    ........
    
    Function getDimensions(var As Variant) As Long
        On Error GoTo Err
        
        Dim i As Long
        Dim tmp As Long
        
        i = 0
        Do While True
            i = i + 1
            tmp = UBound(var, i)
        Loop
        
    Err:
        getDimensions = i - 1
        On Error GoTo 0
        Err.Clear
    
    End Function
    
    
    Function TransposeDim(v As Variant) As Variant
    ' Convert 1D Array to 2D Array (1 -Based)
        Dim x As Long, y As Long, Xupper As Long, Yupper As Long
        Dim tempArray As Variant
    
        on error resume next
        Xupper = UBound(v, 2)
        if err.number <>0 then
            Redim Preserve v(1 to ubound(v), 1 to 1)
           Xupper = UBound(v, 2)   
        endif
        on error goto 0
    
        Yupper = UBound(v, 1)
    
        ReDim tempArray(1 To Xupper, 1 To Yupper)
        For x = 1 To Xupper
            For y = 1 To Yupper
                tempArray(x, y) = v(y, x)
            Next y
        Next x
    
        TransposeDim = tempArray
    End Function
    There is no way to attach a powerpoint pptx file, so sharing the powerpoint template file from google drive.
    Attached Files Attached Files
    Last edited by junoon; 12-18-2019 at 11:36 AM. Reason: attached sample.xlsm file. But unable to attach sample pptx file

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Index/Match greater than 255 characters using LEFT function
    By Groovicles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-14-2016, 01:24 PM
  2. How to handle duplicate data using index and match function
    By zackdy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2014, 02:09 AM
  3. How to handle duplicate data using index and match function
    By zackdy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2014, 11:11 PM
  4. How To Handle Corporate Custom VBA Code for Excel
    By BlueCollarCritic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2011, 01:26 PM
  5. Replies: 1
    Last Post: 07-06-2010, 06:06 PM
  6. How to handle non-english characters in VBA?
    By Zepher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2009, 11:19 PM
  7. Emulate Index/Match combo function w/ VBA custom function
    By Spencer Hutton in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2005, 01:06 PM

Tags for this Thread

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