Macro doesn't work on another computer

Jumparound

New Member
Joined
Aug 4, 2015
Messages
45
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have cobbled together some code from various web pages (so it is probably a complete mess) that copies data (B12:B until last data and E12:M until last data) from the worksheet List, pastes it into two other worksheets (Con Note and Drum List) in cell A2. It sorts the data by column G then F and sets page breaks on the Drum List worksheet so that those with the same data in column G are printed together and those with different data are printed separately. Hopefully that explains it sufficiently. This works as intended on my PC and two others I have tried but it gets an error on a third persons PC.

On the third PC the error given is "Error 483 Object does not support this property or method." This is the line that is highlighted:

VBA Code:
.SortFields.Add2 Key:=Range("F2:F200" _
 ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

This is the complete code:

VBA Code:
Sub CopyData()
Dim a As Integer
Dim b As Integer
With Worksheets("Con Note").Range("A2:J400")
    .ClearContents
    .ClearFormats
    End With
With Worksheets("Drum List").Range("A2:J400")
    .ClearContents
    .ClearFormats
    End With
Dim StartRow As Long, LastVal, ThisVal, lRow As Long, i As Long
    a = Worksheets("List").Range("B12").End(xlDown).Row + 1
    Sheets("List").Range("B12:B" & a - 1).Copy
    Sheets("Con Note").Range("A2").PasteSpecial xlPasteValues
    Sheets("Con Note").Range("A2").PasteSpecial xlPasteFormats
    Sheets("List").Range("E12:M" & a - 1).Copy
    Sheets("Con Note").Range("B2").PasteSpecial xlPasteValues
    Sheets("Con Note").Range("B2").PasteSpecial xlPasteFormats
b = Worksheets("Con Note").Range("A1").End(xlDown).Row + 1
Worksheets("Con Note").Activate

With ActiveSheet.Sort
    .SortFields.Clear
    .SortFields.Add2 Key:=Range("F2:F200" _
        ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    .SortFields.Add2 Key:=Range("G2:G200" _
        ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    End With
    With ActiveWorkbook.Worksheets("Con Note").Sort
        .SetRange Range("A1:J200")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    With ActiveSheet
    .PageSetup.PrintArea = "A1:J" & b - 1
    End With
    
    If ActiveSheet.VPageBreaks.Count > 0 Then ActiveSheet.VPageBreaks(1).DragOff xlToRight, 1
    Sheets("Con Note").Range("A2:J" & b - 1).Copy
    Sheets("Drum List").Range("A2").PasteSpecial xlPasteValues
    Sheets("Drum List").Range("A2").PasteSpecial xlPasteFormats
  
  Worksheets("Drum List").Activate
 ActiveSheet.ResetAllPageBreaks
    StartRow = 2
    lRow = Range("G2").End(xlDown).Row
    LastVal = Cells(StartRow, 7).Value
    For i = StartRow To lRow
        ThisVal = Cells(i, 7).Value
            If Not ThisVal = LastVal Then
                ActiveSheet.HPageBreaks.Add before:=Cells(i, 7)
            If ActiveSheet.VPageBreaks.Count > 0 Then ActiveSheet.VPageBreaks(1).DragOff xlToRight, 1
            End If
        LastVal = ThisVal
    Next i
    With ActiveSheet
    .PageSetup.PrintArea = "A1:J" & lRow
    .PageSetup.PrintTitleRows = "$1:$1"
    End With
    Range("A1").Select
End Sub

We are using the same version of Excel, references are the same. Any ideas what may be causing it?

Thank you
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

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