Overflow Error but no idea how - using Variants for arrays

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
243
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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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,214,819
Messages
6,121,739
Members
449,050
Latest member
excelknuckles

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