I want to write to an excel using row/column numbers instead of range names. The only way I've found to do it was with the .Cells property but I always get an error 0x800A03EC when I try to use it. I tried to simplify it as much as possible to figure out how to make it work. The code bellow works for "test1" and I get the error when it tries to write "test2". I'm running excel 2016 and the latest version of visual studio on W10
Dim xlApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlWorkBook = xlApp.Workbooks.Add
xlApp.Visible = True
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
With xlWorkSheet
.Range("A1").Value = "test1"
.Range(.Cells(8, 8)).Value = "test2"
End With
Can someone help me figure out how to fix it or knows an alternative method to do it ?
.Range(.Cells(8, 8)).Value = "test2"
Take out the .Range(). All that line needs to be is:
.Cells(8,8).Value = "test2"