Why do I get this VBA error message?

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
I have a table ("Fruit") in sheet "Fruit" which is comprised of the header (row 1) and then a single row in the body.

The columns are:

Apples
Bananas
Total Fruit

I have no data in row 1, it is simply blank.

If I input the following code into a vba module, it works fine.

Code:
Sub Fruit()

Dim tblFruit As ListObject
Dim wb As Workbook
Dim ws As Worksheet


Set wb = ThisWorkbook
Set ws = wb.Worksheets("Fruit")
Set tblFruit = ws.ListObjects("Fruit")


tblFruit.ListColumns("Total Fruit").DataBodyRange.FormulaArray = "=Array Formula Here"


End Sub

The formula is placed in-cell in column Fruit Total.

The formula is an array formula that normally I would input in-cell via CSE.

If I add additional columns after running the VBA, the formula auto-fills down to each new row, which is what I want.

The issue I am having is if I have more than one row in my table body before running the code, when I run the code I get an error message.

It states that it is unable to set the the ArrayFromula property of the range class.

Why does it work when there is a single row in the body of the table, but when there are >1, it errors?

How can I go about fixing this?

Thanks in advance for your time and assistance!

-Spydey
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try
Code:
tblFruit.ListColumns("Total fruit").DataBodyRange.Rows(1).FormulaArray
 
Upvote 0
Try
Code:
tblFruit.ListColumns("Total fruit").DataBodyRange.Rows(1).FormulaArray

Hey there Fluff!! Thanks for the response. I will give that a try here in a moment.

-Spydey

P.S. Just tried it and worked great!! Thank you for your assistance!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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