Script works on one PC, but not another

cierrasmadre

New Member
Joined
Jun 14, 2017
Messages
9
I have a script I've been using for weeks now with NO problems. I emailed it to someone so they can cover for me when I'm out. I sat to train them in the process and watched them work through the process the same way I do it. They get to the point of opening the developer window, insert Module, and copy/paste the script in exactly as I have it, but when they run it they get an error message. When we click Debug it shows us the error, but it looks the exact same as on my computer. Their spreadsheet looks like mine as well. If we remove these few lines from the script then it finishes with no problems and we simply have to manually do the task of these few lines.

Any idea why a script would work perfectly on one computer, but a few lines of it have problems on another?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
It would be much easier to answer the question if we could see the code that causes the problem, and know what the actual error message is.
 
Upvote 0
When we click Debug it shows us the error, but it looks the exact same as on my computer. Their spreadsheet looks like mine as well. If we remove these few lines from the script then it finishes with no problems and we simply have to manually do the task of these few lines.
If you post those few lines, it would probably give us a big clue as to what it doesn't like.

A few possible reasons include:
- You are running different versions of Excel
- You have different VBA libraries enabled (from your computer, in the VB Editor, from the Tools menu, select References, and note all the selected references; do the same and compare on the other computer, checking for missing libraries)
- You have code that has some specific file path references that the other user does not have access to
 
Upvote 0
She is running Excel v.15 and I'm on v.16. This is the only difference we've found. VBA libraries match. The script does not reference other spreadsheets, tables, or files. It's shifting some columns, renaming some, reformatting some, and filling in some data that can't be left blank.

I prepped the spreadsheet up to the point that we use the script and ran it. It works. I sent the prepped spreadsheet to her to run the same script and it gave her an Error. Run-time error '1004': AutoFill method of Range class failed.

When we click Debug it takes us to a few steps into the script and highlights the 2nd row below (Selection.AutoFill Destination). If we delete this section of the script it continues running for her with no problem.

Code:
lnglastrow = ActiveSheet.UsedRange.Rows.Count
 
    Selection.AutoFill Destination:=Range("C2:E" & lnglastrow)
    Columns("F:G").Select
    Selection.NumberFormat = "mm/dd/yyyy"
    Cells.Select
    Cells.EntireColumn.AutoFit
    Application.CutCopyMode = False
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

Any idea why this works for me and not her when we're using the exact same spreadsheet?
 
Upvote 0
What's actually selected when the code runs?

What are you trying to autofill?

Does this work?
Code:
    lnglastrow = ActiveSheet.UsedRange.Rows.Count
 
    Range("C2:E2").AutoFill Destination:=Range("C2:E" & lnglastrow)

    Columns("F:G").NumberFormat = "mm/dd/yyyy"

    Cells.EntireColumn.AutoFit

    Application.CutCopyMode = False

    With Cells.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
 
Upvote 0
Thank you. This is usable. This section of my original script takes Cell C2 and copies the data over to columns D and E then autofills down to the bottom of the rows for C-E. When we use this altered script it fills in Column C down to the bottom and across D2 and E2, but does not auto fill down to the bottom of columns D & E.

This doesn't do everything it does for me when I run the script, but gets my coworker a few steps further in the process so is much better for her by cutting out a few more manual steps without getting an error message. Although we're still unsure why the script runs for me with no problems, but not for her.
 
Upvote 0
I had to make an assumption so used C2:E2, try this instead.
Code:
Range("C2").AutoFill Destination:=Range("C2:E" & lnglastrow)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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