Error 438. Excel VBA cells() = Excel.range()

help_for_excel

Board Regular
Joined
Feb 24, 2012
Messages
72
I have a code which is giving me error.

(It is part of larger code)

Dim XData As Excel.Range
Dim nRow AS long
Dim nCol As long
.....
.....
For nRow = 1 To XData.Rows.Count
For nCol = 1 To XData.Columns.Count
.Cells(nRow, nCol) = XData.Cells(nRow, nCol)


When I de-bug code line by line, it gives error 438: Object doesn't support this property or method.

Help is much appreciated.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Dim XData As Excel.Range
Dim nRow AS long
Dim nCol As long
.....
.....
For nRow = 1 To XData.Rows.Count
For nCol = 1 To XData.Columns.Count
.Cells(nRow, nCol) = XData.Cells(nRow, nCol)

At first blush, it is missing an object before .Cells in the last line.

Perhaps there is a With declaration above, but if not you will need to put something before .Cells whether it be Activesheet or XData (not sure what this is defined as), or something else.
 
Upvote 0
You have .Cells but nothing in front of it.

Is it associated with a worksheet/range via a With?
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,538
Members
449,038
Latest member
Guest1337

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