VBA code don't copy all the data in a column to another column, only partial data in Mac OS

Zem32619

New Member
Joined
Jul 2, 2021
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hi Excel Masters.

Am doing a macro that should copy all data in a column to another column but it only copies partial data. The code works on Windows perfectly, but when using Mac, it only copies partial data. Can anyone pls extend some help, would be very much appreciated. Been stuck here for a day now. Thank you so much in advance.

Sheets("Sheet1").Select
Cells.Select
Selection.copy
Workbooks.Add
Cells.Select
ActiveSheet.Paste
'Range("L2:L" & lr).copy Destination:=Range("K2")
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.copy
Range("K2").Select
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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Can you describe what you are trying to achieve.
Currrently the macro is:
  1. creating a new workbook with a copy of sheet 1
  2. it is copying column L to column K twice
    1. The first time it is copied as values only
    2. The second time is is a straight copy totally defeats the purpose of the values only copy.
      Do you want this as value only or a full copy ?
  3. Deleting column L:O
  4. Deleting column V (is this definitely the right column since the original V will have moved due to deleting L:O)
If you can clarify item 2, I can give you some cleaned up to code to try to see if it fixes the issue.
 
Upvote 0
Can you describe what you are trying to achieve.
Currrently the macro is:
  1. creating a new workbook with a copy of sheet 1
  2. it is copying column L to column K twice
    1. The first time it is copied as values only
    2. The second time is is a straight copy totally defeats the purpose of the values only copy.
      Do you want this as value only or a full copy ?
  3. Deleting column L:O
  4. Deleting column V (is this definitely the right column since the original V will have moved due to deleting L:O)
If you can clarify item 2, I can give you some cleaned up to code to try to see if it fixes the issue.
Hi Alex.

Yes, I want to copy all the data in column L to column K as value only. Currently, it copies only partial data (as values) in column L to K. Thanks.
 
Upvote 0
Try this:-
VBA Code:
Sub testTrimmed()

    Dim newWB As Workbook
    Dim newSht As Worksheet
    Dim lastRow As Long

    ' Copy whole of Sheet1 to a new workbook
    ActiveSheet.Copy
    Set newWB = ActiveWorkbook
    Set newSht = ActiveSheet    
    
    ' in New workbook
    With newSht
        lastRow = .Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
        ' Copy L2 to Last Row to Column K values only
        .Range("L2:L" & lastRow).Copy
        .Range("K2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        
        'Delete column L:O
        .Columns("L:O").Delete
    
        'Deleted Column V
        .Columns("V:V").Delete
    
        .Range("A1").Select
    End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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