Macro no longer working

Copper Contributor

I have been using a spreadsheet that friend made a few years ago that has a macro embedded in it. This past week, Excel has updated to a newer version and now I am receiving a Run-Time error message and am unable to run the macro. 

 

Here is the Runtime Error:

RGee77_0-1696511426897.png

 

When I click on "Debug", I'm brought to the Macro code and this part is highlighted:

RGee77_1-1696511472069.png

(If the image is too small, the part highlighted reads "Selection.PasteSpecial Paste:=xlPasteValues, Operation:xlNone, SkipBlanks _ :=False, Transpose:=False")

 

I'm assuming that something in this part of the code is no longer compatible with the most recent Excel update. Any ideas on how to tweak this code so that I can run the macro? 

 

Thanks in advance.  

 

5 Replies

@RGee77 

I have no idea why the error occurs, but try replacing the lines

    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

with

    With ActiveSheet.UsedRange
        .Value = .Value
    End With
Thanks for the response- I replaced those lines and got a different Run-time error: '1004" Method 'Range' of object'_Global" failed.

And when I click on "Debug" the next line "Range("Table1[[#Headers],[Record ID'#]]").Select" is highlighted.

Any ideas??



@RGee77 

Since you activate another sheet immediately after that, the line

 

Range("Table1[[#Headers],[Record ID'#]]").Select

 

isn't needed. I'd either remove it or turn it into a comment by inserting an apostrophe (single quote) before it.

@Hans Vogelaar 

 

And now a this section is now highlighted: 

RGee77_0-1696518854096.png

ActiveSheet.PivotTables("PivotTable1").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Table1", Version _
:=xlPivotTableVersion15)

 

(Sorry, I'm not really knowledgeable with the coding part of macros...)

@RGee77 

This is going to take too long.

Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?