+ Reply to Thread
Results 1 to 2 of 2

Type Mismatch when Transposing 65556 size Array into Range

Hybrid View

tngengineer Type Mismatch when... 02-22-2014, 05:39 PM
watersev Re: Type Mismatch when... 02-22-2014, 06:18 PM
  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Type Mismatch when Transposing 65556 size Array into Range

    I was looking for a worksheet with vba to do FFT beyond the Excel internal 4096 limit. With this Forum's help I did find one (without vba) that would do the trick.
    I wanted to try my hand at writing code to do it faster. The attached does just that.
    Everything worked fine until I went beyond 32k samples. The next higher 2^n value for data size to feed the FFT is 65556. When I tried this quantity of samples I got Runtime Error (13) type mismatch when attempting to write the array back to the worksheet using the "transpose" method.
    If I remember correctly, 32k worked.
    I bookmarked the line in question in the attached file.
    Destination.Value = Application.Transpose(ReData) 'Transpose Array and write to destination range
    Is there some limit to the size of the array that can be transposed and placed into a range? If so, is there another way to do this?

    I do not need to re-write the data, but I use this same method elsewhere to write the FFT output. It it fails writing the input data back, it will probably fail when writing the FFT results.

    PS. Please excuse the sloppy code. My first vba project since about 1997 and my second in total.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Type Mismatch when Transposing 65556 size Array into Range

    hi tngengineer, welcome to Excelforum.

    Transpose function you use does have a limitation of 65536 items. Unfortunately there is no trick to overcome this limitation and still use Transpose function.

    The solution I can suggest would require pretty much changes to the code. As I see in you code you create one-dimensional array with values and then use transpose it to make it vertical. You can create that array vertical from the start (two-dimensional) and avoid Transpose.

    Example (simplified) to show what I mean:

    Sub example()
    
    Dim arr(1 To 100), i As Long
    
    For i = 1 To 100
        arr(i) = i
    Next
    
    Range("a1:a100") = Application.Transpose(arr)
    
    End Sub
    
    Sub example_no_transpose()
    
    Dim arr(1 To 100, 1 To 1), i As Long
    
    For i = 1 To 100
        arr(i, 1) = i
    Next
    
    Range("a1:a100") = arr
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Type Mismatch and Subscript out of Range for Static Array
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2012, 06:42 PM
  2. Type mismatch error assigning range to array......
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-11-2012, 06:27 PM
  3. Type Mismatch: array or user defined type expected
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2006, 10:45 AM
  4. Array problem: Key words-Variant Array, single-element, type mismatch error
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2005, 01:54 AM
  5. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 PM

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