Macro didn't copy all the rows from one sheet to another workbook using Mac, but works fine on Windows

Status
Not open for further replies.

Zem32619

New Member
Joined
Jul 2, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi. Been trying to figure out my code that would copy all content on sheet 1 to another worksheet when the macro is run in Mac, but works perfectly when run on Windows.
Can anyone here pls extend some generous help, been stuck here and do some google search but still unlucky to find solutions. Below is my code. Thank you in advance.

Sheets("Sheet1").Select
Range("$A$1:$AG$" & lr).Select ' Select the range with data
Cells.Select
Selection.copy
Workbooks.Add
Cells.Select
ActiveSheet.Paste
Range("L2:L" & lr).copy Destination:=Range("K2")
Selection.copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("L:O").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
Columns("V:V").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A1").Select
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,183
Office Version
  1. 2007
Platform
  1. Windows
Range("$A$1:$AG$" & lr).Select
The macro you put is not complete. The value of the variable lr is missing.
In addition to putting your full macro.
You could explain in your words what you want to copy and where you want to paste it.
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,598
Office Version
  1. 2013
Platform
  1. Windows
Try ...
VBA Code:
Sub zem32619()
    Sheets("Sheet1").Copy
    With ActiveSheet
        .Columns("L:O").Delete Shift:=xlToLeft
        .Columns("V:V").Delete Shift:=xlToLeft
        .UsedRange.Value = .UsedRange.Value
        .Range("A1").Select
    End With
End Sub
 

Zem32619

New Member
Joined
Jul 2, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
The macro you put is not complete. The value of the variable lr is missing.
In addition to putting your full macro.
You could explain in your words what you want to copy and where you want to paste it.
HI DanteAmor,
Yes, I just want to copy the whole data in Sheet1 to another workbook. This code works for WIndows, but not on Mac as it just copies partial data.

Sub Copy_Sheet()
Sheets("Sheet1").Select
lr = Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Range("$A$1:$AG$" & lr).Select ' Select the range with data
Cells.Select
Selection.copy
Workbooks.Add
Cells.Select
ActiveSheet.Paste
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,183
Office Version
  1. 2007
Platform
  1. Windows
It's a bit confusing, that's why I asked you for an explanation with your words, but now you put another macro, and it's still confusing for me.
In this line you select a range of cells:
Range("$A$1:$AG$" & lr).Select ' Select the range with data


But in this line you select all the cells, this disables the previous selection.
Cells.Select
So you are copying all cells.

____________________________
According to your macro, which cells are copied on windows and which cells on the mac?
 
Status
Not open for further replies.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,117
Messages
5,768,213
Members
425,459
Latest member
Danniey

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
Top