Why won't split work for me?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,531
Office Version
  1. 365
Platform
  1. Windows
I copied this example from one of the M$FT pages, but when I try it, it gets a Run-time error "13": Type mismatch.

VBA Code:
Dim sPrioAskCols As String
sPrioAskCols = "1 4 7 10 13"
Dim PrioAskCols() As Variant
PrioAskCols = Split(sPrioAskCols)

What am I doing wrong?
 
I don't think the method is all that important although my preference is for declaring the variable as Variant (like you plan to do)... that way, VB will use the value as needed (you will not have to convert it to Longs first). And as you noted earlier, VB will convert a string number to a real number when you use it in a calculation but I think doing that may require an extra internal step on VB's part.
Perfect, thank you.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I made this little table for future reference. As a little "thank you" for all the help, I'm posting it here in case it might be helpful to others.

1629994493300.png

Let me know if there are any other examples I should include.
aaa
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,054
Latest member
juliecooper255

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