Macro that ran in Excel 2010 VBA doesn't work in 2000 VBA.

billfinn

Board Regular
Joined
Jun 7, 2018
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
Good morning,
I need to make several macros created on Excel 2010 VBA run on Excel 2000 and so far it's been a real clinic. The macros run perfectly on Excel 2010.
I got one working after a while, but this next has me stymied. It's pretty much over my head. I commented out the error handler so I could track down the error.

The macro errors on the line;
Windows("Estimator.xlsm").Activate

I tried replacing Windows with Workbooks but got the same error.

If I comment that line out as a test
it next complains about the line;
Range("A:D").Replace Ary(i), "=xxx", xlWhole, , False, , False, FalseI will be extremely grateful for any suggestion or input
Thanks much!
Bill



Code:
Sub Strip_Page_Report_Headers()    'Macro to strip out Report and Page headings to leave an Excel File with columns properly formatted.
'Timer - comment out the three lines below if you don't want the timer to run
Dim StartTime As Double
Dim MinutesElapsed As String
'Remember time when macro starts
StartTime = Timer


    On Error GoTo ErrorHandler
With Application
    .ScreenUpdating = False
    .DisplayStatusBar = False
    .Calculation = xlCalculationManual
    .EnableEvents = False
    .PrintCommunication = False
End With


    Windows("Estimator.xlsm").Activate  'Go to the Estimating Tool
    Sheets("Item Master").Select      'Select the Test Data worksheet in the Estimating tool
    Selection.EntireColumn.Hidden = False
    Dim Ary As Variant
    Dim i As Long
    Ary = Array("*QUERY*", "*INVMASTB*", "*INVMASTAAA*", "*LIBRARY*", "*PRICEMSM*", "*DATE*", "*REPORT", "*invmast*", "Item", "Prod", "Pricing", "*Cost*", "*:*", "*DELETED*", "*EDIORGI*", "*DELETE*", "*FORMAT*")
    For i = 0 To UBound(Ary)
    Range("A:D").Replace Ary(i), "=xxx", xlWhole, , False, , False, False
    Next i


    For i = 1 To 15
    On Error Resume Next
    Columns(i).SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
    On Error GoTo 0
Next


'Add Column Labels
Rows(1).Insert Shift:=xlDown
    Range("A1").FormulaR1C1 = "ITEM"
    Range("B1").FormulaR1C1 = "DESCRIPTION"
    Range("C1").FormulaR1C1 = "COST"


  ' Set Column C as currency
Worksheets("Item Master").Columns("C").NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"


Columns.AutoFit
  
ErrorHandler:
With Application
    .ScreenUpdating = True
    .DisplayStatusBar = True
    .Calculation = xlCalculationAutomatic
    .EnableEvents = True
    .PrintCommunication = True
End With


'Timer end code - comment out two lines below if you don't want the timer to run
  MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
  MsgBox "This code ran successfully in " & MinutesElapsed, vbInformation




End Sub
 
What is the error message?
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Compile Error:
Wrong number of arguments or invalid property assignment
 
Upvote 0
Ok, in 2000 record a macro of you replacing a single value (ie Ctrl H) & post the code.
 
Upvote 0
Code listed below as requested

Code:
Sub Macro1()'
' Macro1 Macro
' Macro recorded 9/4/2018 by user
'


'
    Cells.FindNext(After:=ActiveCell).Activate
    ActiveCell.Replace What:="=xxx", Replacement:="test", LookAt:=xlWhole, _
        SearchOrder:=xlByRows, MatchCase:=False
    Cells.Find(What:="=xxx", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False).Activate
End Sub
 
Upvote 0
In that case try
Code:
For i = 0 To UBound(ary)
    Range("A:H").Replace what:=ary(i), Replacement:="=xxx", LookAt:=xlWhole, MatchCase:=False
Next i
 
Upvote 0
Thanks very much Fluff,
That got me through that error but it then stopped at
Code:
Columns(i).SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
with a Run Time Error 1004. Unable to get the SpecialCells property of the Range class.
Bill

 
Upvote 0
What if you try
Code:
SpecialCells(xlCellTypeFormulas, 16)
 
Upvote 0
I tried that and ended up with the same error in the same place
 
Upvote 0
Ok, start recording a macro > Ctrl G > Special > Formulas > Ensure only "Errors" is checked > OK
What code does that give?
 
Upvote 0
Here is the code from that exercise
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 9/4/2018 by user
'


'
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,674
Members
449,463
Latest member
Jojomen56

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