Possible reasons behind error 1004(Back to normal after reopening excel file)

yxz152830

Active Member
Joined
Oct 6, 2021
Messages
385
Office Version
  1. 365
Platform
  1. Windows
Maesters,
My code had been running normally for least 50+ times. I was writing some really simple follow-up codes which I'm 100% sure that have nothing to conflict with my main sub. All of a sudden, as I retested my main sub, 1004 error occurred. Another command button containing another sub stopped working as well. But for this command button, the sub assigned could be run in the VBA editing window.
Anyways, I saved file, which meant if there was an error, it would have been saved as well, and closed all excel windows. I reopened and found that the codes were back to normal again.
So what is the problem behind all these and how do I prevent it from happening again ? Or is it just one of the many glitches that can't be avoided?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,
VBA Runtime Error 1004 occurs when executing a macro but display’s several different messages.

It would be helpful to forum to share the error message you are getting along with your code highlighting where the error occurs. Maybe then someone can offer guidance.


Dave
 
Upvote 0
The ".Refresh" part was where the debug highlighted. I don't remember what the error 1004 message said in detail any more.... the code went back to normal after I restarted excel...
The weird thing about this error was that it seemed like an overall collapse. Another command button with completely non related macro went down as well, but I could still run the code in VBA edit window though.

VBA Code:
With ActiveSheet.ListObjects.Add(SourceType:=4, Source:=ActiveWorkbook. _
        connections(qname), Destination:=Sheets("flight").Cells(10000, 1).End(xlUp).Offset(1, 0)).TableObject
        .RowNumbers = False
        .PreserveFormatting = True
        .RefreshStyle = 1
        .AdjustColumnWidth = True
        .ListObject.DisplayName = rname
        .Refresh
End With
 
Upvote 0

Forum statistics

Threads
1,212,929
Messages
6,110,741
Members
448,295
Latest member
Uzair Tahir Khan

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