+ Reply to Thread
Results 1 to 3 of 3

Concatenate Function getting Type mismatch error

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Concatenate Function getting Type mismatch error

    I am trying to concatenate columns with the following code (I know there are many ways to do this but am trying to follow through on this idea) but it is not working, I get "Type mismatch" here:
    Please Login or Register  to view this content.
    Thanks

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by capson; 12-08-2015 at 01:01 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Concatenate Function getting Type mismatch error

    One element within sTemp(x) is a string. The .Transpose function returns an array. Thus a type mismatch error. The fix would be to declare sTemp as a variant. Then each sTemp element is a subarray. Or leave sTemp as a string and join the transposed array like this..

    sTemp(x) = Join(.Transpose(.Transpose(Intersect(UNR, UNR(i, 1).EntireRow).Value2)), ";")

    There are a few other issues with the code which you'll see when you make the above fix. A major limitation will be that the Transpose function doesn't transpose noncontiguous ranges. So for your example, it transposes only columns A:B and excludes columns G and I. I would suggest you read the entire data columns A:I into an array and loop the array to concatenate the required columns row by row. This may seem like brute force, but array processing is fast.

    This only works for columns A:B because of the contiguous range limitation.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-08-2015 at 01:57 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Concatenate Function getting Type mismatch error

    Thanks AlphaFrog, that was a helpful explanation, I will play around with the code but I think that this is not a fruitful approach and will abandon it

+ 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. [SOLVED] Concatenate macro Type Mismatch error
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-12-2014, 02:05 PM
  2. Instr() function giving error: "Type mismatch"
    By arjun.majumdar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-22-2013, 04:17 AM
  3. VBA Function Generating Type Mismatch Error
    By Mediterranean in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2013, 11:22 AM
  4. [SOLVED] 'Type mismatch error' while translating the worksheet function to VBA
    By ramananhrm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 03:02 AM
  5. Replies: 4
    Last Post: 03-27-2013, 12:16 PM
  6. Date array function has type mismatch error...
    By secret2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2011, 02:07 PM
  7. Range and Find function error: Type Mismatch
    By VBNewb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2011, 02:10 PM
  8. [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