I figured out what Nick was suggesting, and the following is the error number & description that I\'m getting:
\'-2147417848 (80010108)\' Automation
Make sure your sheet is not protected with cells locked while doing insert. This could be one of the reason why the code will fail. This code was working for me on one folder, but when I copied the excel macro file to another folder I started getting this error. Since it is only for formatting, I avoided using the below codes altogether and did formatting the usual way and not copying from above rows.
Note that in first code, entire row gets selected and if you have protected cells, it could lead to failure.
'Rows(r + 3 & ":" & r + 3).Select
'Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
This solution works for me:
Before adding rows with Shift:=xlDown delete bottom rows on the worksheet
'ADD THE ROWS YOU WANT
Sheets("XXXXXX").Range("A100000:A100100").EntireRow.Delete
With Selection
.Copy
.Insert Shift:=xlDown
End With
Ok... It's been well over 1 month now, and I've finally fixed this!! Fortunately & Unfortunately, it had absolutely nothing to do with my code. Instead, it was an MS Office Vs. Windows 8 problem. To fix it, I ran the compatability troubleshooter, and all is back to perfect again:
I cannot believe that this is all I had to do the whole time! I actually spent $149 thinking that Microsoft Support could remote in and fix it, but that was an absolute waste! I was transferred to 12+ different people/departments, and still got nothing from them. I finally stumbled across the solution this morning....
Anyway, thanks to everyone who posted and tried to help me with this. I always log off of this site with better VBA skills than I signed on with because of all of you... So Thanks again!
I had the same issue, with some macros that were working for everyone but not 1 person.
I solved it by asking the person to not use a folder that was synced to OneDrive, so be careful when using OneDrive.
I had other cases where OneDrive marked downloaded files from BOX or other file sharing services as read only, and made macros error out. And all you would need to do is open the file, save it and open it up again, but allot of people blamed it on my macros. It took me a while to find the cause, and to find a way to save an reopen the file using macros, before it actually opens...