I found this today on a Youtube turorial and it would save me sooooo much time if I could get it work but Im struggling.
Im using this code to sort data from 2 rows into a single row ready to be transferred to a different sheet.
At the moment, once this has run through its macro, it ends with Cut, then I go another sheet with almost the last row on another sheet showing and Paste and with it not being a full row in view, as soon as I paste, it moves up a line so Im always pasting into an empty row.
Sub FixSort()
'
' FixSort Macro
' Sorts fixture data
'
' Keyboard Shortcut: Ctrl+n
'
Range("B3").Select
Selection.Cut
Range("B2").Select
ActiveSheet.Paste
Range("C7").Select
Selection.Cut
Range("C2").Select
ActiveSheet.Paste
Range("B5").Select
Selection.Cut
Range("D2").Select
ActiveSheet.Paste
Range("C5").Select
Selection.Cut
Range("G2").Select
ActiveSheet.Paste
Range("C9").Select
Selection.Cut
Range("H2").Select
ActiveSheet.Paste
Range("O5").Select
Selection.Cut
Range("I2").Select
ActiveSheet.Paste
Range("O9").Select
Selection.Cut
Range("J2").Select
ActiveSheet.Paste
Range("D5").Select
Selection.Cut
Range("L2").Select
ActiveSheet.Paste
Range("E5").Select
Selection.Cut
Range("M2").Select
ActiveSheet.Paste
Range("D9").Select
Selection.Cut
Range("N2").Select
ActiveSheet.Paste
Range("E9").Select
Selection.Cut
Range("O2").Select
ActiveSheet.Paste
Range("P5").Select
Selection.Cut
Range("P2").Select
ActiveSheet.Paste
Range("L5").Select
Selection.Cut
Range("Q2").Select
ActiveSheet.Paste
Range("P9").Select
Selection.Cut
Range("R2").Select
ActiveSheet.Paste
Range("L9").Select
Selection.Cut
Range("S2").Select
ActiveSheet.Paste
Range("F5").Select
Selection.Cut
Range("T2").Select
ActiveSheet.Paste
Range("M5").Select
Selection.Cut
Range("U2").Select
ActiveSheet.Paste
Range("M9").Select
Selection.Cut
Range("V2").Select
ActiveSheet.Paste
Range("F9").Select
Selection.Cut
Range("W2").Select
ActiveSheet.Paste
Range("H5").Select
Selection.Cut
Range("X2").Select
ActiveSheet.Paste
Range("H9").Select
Selection.Cut
Range("Y2").Select
ActiveSheet.Paste
Range("N9").Select
Selection.Cut
Range("O5").Select
ActiveSheet.Paste
Range("N5:O5").Select
Range("O5").Activate
Selection.Cut
Range("Z2").Select
ActiveSheet.Paste
Range("k1").Select
Selection.Copy
Range("k2").Select
ActiveSheet.Paste
Rows("1:1").Select
Selection.Copy
Rows("2:2").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Rows("3:12").Select
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Cut
End Sub
I do this every day and on some days there can be a many as 300 lines of data to copy
and it takes a lot of time.
The issue at the moment is I keep getting a Complile Error: Invalid use or property
Heres the code I found that I was hoping would speed it up, if I can utilise this and make it repeat until theres no data left to sort it would be a massive help
Sub Macro()
'
' Macro
'
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("SDLsortCONFOR_Backup.xlsm").Worksheets("NEWSORT")
Set wsDest = Workbooks("SDLsortCONFOR_Backup.xlsm").Worksheets("Formatting")
'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("A2:A" & lCopyLastRow).Copy
wsDest.Range ("A" & lDestLastRow)
End Sub
Im getting the error highlighting the .Range part of wsDest.Range at the end of the code.
Im trying to learnt but this is messing with my head, Im guessing this is childsplay level stuff
Im using Excel 2019
Many thanks
Im using this code to sort data from 2 rows into a single row ready to be transferred to a different sheet.
At the moment, once this has run through its macro, it ends with Cut, then I go another sheet with almost the last row on another sheet showing and Paste and with it not being a full row in view, as soon as I paste, it moves up a line so Im always pasting into an empty row.
Sub FixSort()
'
' FixSort Macro
' Sorts fixture data
'
' Keyboard Shortcut: Ctrl+n
'
Range("B3").Select
Selection.Cut
Range("B2").Select
ActiveSheet.Paste
Range("C7").Select
Selection.Cut
Range("C2").Select
ActiveSheet.Paste
Range("B5").Select
Selection.Cut
Range("D2").Select
ActiveSheet.Paste
Range("C5").Select
Selection.Cut
Range("G2").Select
ActiveSheet.Paste
Range("C9").Select
Selection.Cut
Range("H2").Select
ActiveSheet.Paste
Range("O5").Select
Selection.Cut
Range("I2").Select
ActiveSheet.Paste
Range("O9").Select
Selection.Cut
Range("J2").Select
ActiveSheet.Paste
Range("D5").Select
Selection.Cut
Range("L2").Select
ActiveSheet.Paste
Range("E5").Select
Selection.Cut
Range("M2").Select
ActiveSheet.Paste
Range("D9").Select
Selection.Cut
Range("N2").Select
ActiveSheet.Paste
Range("E9").Select
Selection.Cut
Range("O2").Select
ActiveSheet.Paste
Range("P5").Select
Selection.Cut
Range("P2").Select
ActiveSheet.Paste
Range("L5").Select
Selection.Cut
Range("Q2").Select
ActiveSheet.Paste
Range("P9").Select
Selection.Cut
Range("R2").Select
ActiveSheet.Paste
Range("L9").Select
Selection.Cut
Range("S2").Select
ActiveSheet.Paste
Range("F5").Select
Selection.Cut
Range("T2").Select
ActiveSheet.Paste
Range("M5").Select
Selection.Cut
Range("U2").Select
ActiveSheet.Paste
Range("M9").Select
Selection.Cut
Range("V2").Select
ActiveSheet.Paste
Range("F9").Select
Selection.Cut
Range("W2").Select
ActiveSheet.Paste
Range("H5").Select
Selection.Cut
Range("X2").Select
ActiveSheet.Paste
Range("H9").Select
Selection.Cut
Range("Y2").Select
ActiveSheet.Paste
Range("N9").Select
Selection.Cut
Range("O5").Select
ActiveSheet.Paste
Range("N5:O5").Select
Range("O5").Activate
Selection.Cut
Range("Z2").Select
ActiveSheet.Paste
Range("k1").Select
Selection.Copy
Range("k2").Select
ActiveSheet.Paste
Rows("1:1").Select
Selection.Copy
Rows("2:2").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Rows("3:12").Select
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Cut
End Sub
I do this every day and on some days there can be a many as 300 lines of data to copy
and it takes a lot of time.
The issue at the moment is I keep getting a Complile Error: Invalid use or property
Heres the code I found that I was hoping would speed it up, if I can utilise this and make it repeat until theres no data left to sort it would be a massive help
Sub Macro()
'
' Macro
'
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("SDLsortCONFOR_Backup.xlsm").Worksheets("NEWSORT")
Set wsDest = Workbooks("SDLsortCONFOR_Backup.xlsm").Worksheets("Formatting")
'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("A2:A" & lCopyLastRow).Copy
wsDest.Range ("A" & lDestLastRow)
End Sub
Im getting the error highlighting the .Range part of wsDest.Range at the end of the code.
Im trying to learnt but this is messing with my head, Im guessing this is childsplay level stuff
Im using Excel 2019
Many thanks