Overflow Error but no idea how - using Variants for arrays

TheRedCardinal

Active Member
Joined
Jul 11, 2019
Messages
252
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have a commonly used bit of code that loads a whole worksheet into an array for data manipulation.

It looks like this:

VBA Code:
Set WBk1 = ThisWorkbook
Set WS1 = WBk1.Sheets("5. Purchases")
Set WS2 = WBk1.Sheets("10. Input Summary")
Set WS3 = WBk1.Sheets("1. Start")

Dim PurchaseData As Variant, Inputs As Variant, TCodes As Variant

PurchaseData = WS1.UsedRange
Inputs = WS2.Range("InputSummary")

I'm getting an overflow error on the "PurchaseData = WS1.UsedRange" line - the used range, confirmed by checking in Immediate is 16 columns by 4360 rows, and much smaller than other instances of using this process.

Can anybody see what I've done wrong here?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Does it work if you use:

VBA Code:
PurchaseData = WS1.UsedRange.value2
 
Upvote 0
Solved it now - there was a value in the column that was a number but too big (I think) - fixed it by converting that column to text.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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