• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

"run-time error'1004' application-defined or object-defined error

wayneseymour01

New Member
Hi I a strange and unexplained insight occurred while contemplating what to do next. While imputing data into a input cellsI tried to only input some data then run the "save" macro( looking for possible error during the data input stage). I discovered as long as my cursor is still set in the cell(active) I just entered data into I could not run the macro (greyed out) but I can press the button attached to the macro, this results in the fore-mentioned error. However. if focus(click to a different cell) is on a different area of the worksheet(make sure last data input cell is no longer active) and I press the "save button" everything is fine no errors. So once the last cell that you are entering data into is active and you try to save you get the error.(???????) I have attached the file and also two screen-shots of the error. On the work sheet screen shot you will see that the input cell next to "Bill No. is the cell still acrive after excuting the save button which is designed to be .visible=false behind the "AddNew button".T?he data is added as it should be but because tne last input cell is active I get the error.
 

Attachments

  • Cignal Monthly Payments_Cignal.xlsm
    150.5 KB · Views: 10
  • excel error on save click.png
    excel error on save click.png
    343.4 KB · Views: 20
  • excel error on save clickvba editor.png
    excel error on save clickvba editor.png
    185 KB · Views: 16
Looking at both your screen shots together, I can see that cell B2 is empty.
On your yellow-highlighted line in the other screenshot I can see a reference to myVar.value as the row argument to Cells. Since myVar is cell B2, this too will be empty. This will throw an error.
You need to be looking at what populates cell B2 and when, throughout the rest of your code.
Or, you may need to temporarily stop the WorkSheet_Change event from firing elsewhere in the code, when the code itself is changing the sheet. Check out Application.EnableEvents = True/False.
Perhaps:
upload_2018-9-10_13-25-28.png
 
Last edited:
Back
Top