Trouble with variant used with range.text

jameserenshaw

New Member
Joined
Oct 14, 2013
Messages
2
Hi,

I'm having trouble with a variant when assigned the text values of a range. The piece of code I'm testing is below:

Code:
Dim RecordRows As Variant
RecordRows = Range("A7:AB46").text
MsgBox (RecordRows(2, 1))

It gives me a type mismatch error, which is odd considering a variant should be able to handle any data type. But if I use 'RecordRows = Range("A7:AB46").value' then it works fine. Only problem is that I need exactly what is in the cell, not the value. Having the value will cause me lots of checking, changing and general headaches.

Any help would be appreciated.

Thanks,

James
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
The Text property won't return an array. It will return a String if all the cells have the same content, or Null otherwise. Either way, you'll get a type mismatch when you try and use it as an array.
 
Upvote 0
Thanks,

Not the answer I wanted, but at least I know why it's not working now. I guess I'll have to check everything once it's come through.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,216,134
Messages
6,129,070
Members
449,485
Latest member
greggy

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