I have the source workbook as TestDatatwo workbooks: Source.xlsm, sheet= Orig and selecting specific rows from its Sheet1 Destination.xlsm, sheet=New
I am then attemptingtrying to takemove data between these sheets in a specific way: Example of both sheets before running the macro (the column ordering is on purpose)

In the Orig sheet, cell F1 is storing todays date in the following format: dd mmm yy
My objective is to take only the rows from Orig with todays date and place all of them within Sheet1in a specific ordering to the end of AutoBE.xlsmthe New sheet. So that after running the macro, New looks like:
TesData.xlsm has
Any suggestions as to how to progress would be amazing
I have the following code and both TestData and AutoBE are opensnippets to start to form a solution, all saved in Source. AutoBE will already have existing rows so the copied rows must eb appended atxlsm. This correctly select the bottom two rows of the Sheet1Orig since they have todays date in AutoBE.
Declarationscolumn D
Sub CopyWorksheet() 'Source Dim swb As Workbook: Set swb = Workbooks("TestData.xlsm") Dim sws As Worksheet: Set sws = swb.Worksheets("Sheet1") 'Destination Dim dwb As Workbook: Set dwb = Workbooks("AutoBE.xlsm") ' Reference the old worksheet... Dim dwsOld As Worksheet: Set dwsOld = dwb.WorksheetsSelectTodayRows("Sheet1") ' and store its name and its code name in variables. Dim dName As String: dName = dwsOld.Name Dim dCodeName As String: dCodeName = dwsOld.CodeName Dim tableR As Range, cell As Range, r As Range Dim s As String
This code is used to select a range of rows that have todays date within their H column, so cell AA1 is storing todays date.So, the last Line, Range(s).Select selects the rows with todays date on Sheet1 in TestData:
Set tableR = Range("H1"D1:H100000"D100000") Set r = Range("AA1""F1") 'want to fix the selection so it should be a cell For Each cell In tableR If cell = r Then s = s & cell.Row & ":" & cell.Row & ", " End If Next cell s = Left(s, Len(s) - 2) Range(s).Select
Now, I am trying to copy these rows/ range into Sheet1 in AutoBE
'Copy. Range(s).Copy After:=dwsOld 'Reference the new (copied) worksheet. Dim dwsNew As Worksheet: Set dwsNew = dwsOld.Next ' Delete the old worksheet. Application.DisplayAlerts = False ' delete without confirmation ' dwsOld.Delete Application.DisplayAlerts = True ' Rename the new worksheet and restore the old code name. dwsNew.Name = dName dwb.VBProject.VBComponents(dwsNew.CodeName).Name = dCodeName End Sub
If I replace the first line with sws.Copy After:=dwsOld it successfully copies the entire sheet1 from TestData into sheet1 of AutoBE. But I'm struggling to only copyThe next step is appending these selected rows in the selection/range
It returns the followingcorrect column ordering to New.
Compile Error: Named argument Not found and highlights 'After:='