Run Time Error 13: Type Mismatch (only 4 lines of code to look at)

Chris Macro

Well-known Member
Joined
Nov 2, 2011
Messages
1,345
Office Version
  1. 365
Platform
  1. Windows
I am getting this error on the 3rd line of my code (MyVariable = Join.....). Any ideas on what could be causing this?

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> Macro1()<br><SPAN style="color:#00007F">Dim</SPAN> Lastrow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> MasterEmailList <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Variant</SPAN>, MyVariable <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><br><br><SPAN style="color:#007F00">'Combine Mill Email Groups into One Large String</SPAN><br>        Lastrow = sheet4.Cells(Rows.Count, "J").End(xlUp).Row<br>        <br>        MasterEmailList = sheet4.Range("J1:J" & Lastrow)<br>        MyVariable = Join(Application.Transpose(MasterEmailList), "; ")<br>        sheet4.Cells(Lastrow + 1, "J") = MyVariable<br>        <br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Ok, I think I solved it. So, I had run the macro once and it worked fine creating the large string in J7 for the Range J1:J6. When I went to go run the macro again, it include the large string from when I had previously run it. That's why I was getting a SUPER long string. I am going to put in some code so I don't run into this problem again.

Theoretically, everything will get deleted after it is used, so I won't run into this problem in real world use. Thanks for the ideas and allowing me to figure out the solution to my problem!!
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Glad to help..

Funny how sometimes troubleshooting leads to answers that are completely different from what you would think the problem was.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top