800A03EC Unknown runtime error

dstelley

New Member
Joined
Jan 24, 2014
Messages
2
I have what is likely a simple answer but I cant see it. I've simplified as much as possible to show the error. This is VBScript manipulating Excel. The below code works fine. The second code does not. It throws a vague 800A03EC Unknown runtime error on the line that works with data.
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
intColumn = 2
for x = 0 to 20
objExcel.Cells(intRow, intColumn).value = x
objExcel.Cells(intRow, intColumn).Select
intRow = x + 1
intColumn = x + 1
next
Set objExcel = nothing
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
intColumn = 2
for x = 0 to 20
strVal = "123R15"
intColumn = right(strVal,2)
objExcel.Cells(intRow, intColumn).value = x
objExcel.Cells(intRow, intColumn).Select
intRow = x + 1
intColumn = x + 1
next
Set objExcel = nothing
the error is on the line objExcel.Cells(intRow, intColumn).value = x Thanks in Advance
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,093
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You need to coerce intColumn to a true number:
Code:
intColumn = clng(right(strVal,2))
 

Watch MrExcel Video

Forum statistics

Threads
1,122,804
Messages
5,598,140
Members
414,214
Latest member
marketingnumbersguy

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
Top