'VBA Runtime Error -2147417848 (80010108) Automation Error

I have an issue in the code VBA , when i want to add new values in my formulas always showing me an error message of debug and the application crash

here my used code :

the main function :

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("data")
Dim last_row As Long
last_row = Application.WorksheetFunction.CountA(sh.Range("A:A"))

When i click in debug button , it going to show me this code of line :

sh.Range("A" & last_row + 1).Value = Me.mat.Value

I am using the OFFICE 365 PRO PLUS



Solution 1:[1]

It's hard to answer your question without seeing the whole code. You should post more details. Is your code running inside of a Form ?

But Lets see what we have....

sh.Range("A" & last_row + 1).Value = Me.mat.Value

Is last_row always greater then zero and always smaller then maximum rows in worksheet (e.g. sh.rows.count-1) ?

What Object is Me pointing to ?

Which kind of Object is Me.mat ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MaMe