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
29
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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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