Please bare with me for my below problem I have been working on this for a 3 months and I cant get my head around it.
I have to explain the whole project so that you can understand what I want my code to do:
I have created a user form which is data entry and it will be used by 3 users at the same time each user on a pc has same excel workbook "ENTRY APPLICATION" and data is entered on a sheet called "NEW ROUND" each user data entries have a serial number that starts with 1 - 1000 for example. and another workbook on a shared folder which is there to have all data entered by 3 users be copied and pasted on the shared workbook "DATABASE", then the data collected on the "DATABASE" to be copied again and pasted on same work book "ENTRY APPLICATION" for the users but in another sheet so that it is mirrors to the shared workbook for the user while sorting so that serial number for the data is sorted correctly for each user, fot that I have same workbook for the 3 users but each one just changed the range for them so that their data be copied on a range so that they dont clear other user data entries, for example : user 1 the paste range A1:N2000, user 2 the paste range is A2001:N4000, user 3 paste range is A4001:N6000 then they all get sorted out when pasted again in their workbook which is "DATA APPLICATION" with the user form.
"DATABASE" workbook which is the shared that all collected data is in it , to prevent duplication entries from users (which is in a different module ) but for now my struggle is I'm trying to have that done by less time and more efficient so that I dont have to use the screenupdate and open activate save close workbooks all the time, which can make work slow and might crash.
I have come to read a great thread here now about Parent Object which apparently save great time and errors for my same needs, but I have no idea what so ever how to reflect that on my userform workbook and how to adjust my code.
please help me adjust my code , hope that I have explained it correctly.
Sub DATA_BASE_ARCHIVE_FullArchive()
Application.ScreenUpdating = False
Windows("ENTRY APPLICATION.xlsm").Activate
Sheets("NEWROUND").Select
Range("A1:N2000").Select
Selection.Copy
Workbooks.Open filename:= _
"\\2-2023\DATABASE.xlsm"
Windows("DATABASE.xlsm").Activate
Range("A2001").Select
Sheets("FullArchive").Paste
Cells.Select
Range("A2001").Activate
Application.CutCopyMode = False
Selection.Copy
Windows("ENTRY APPLICATION.xlsm").Activate
Sheets("ARCHIVE").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("ARCHIVE").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ARCHIVE").Sort.SortFields.ADD Key:=Columns("L:L") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("ARCHIVE").Sort.SortFields.ADD Key:=Columns("A:A") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("ARCHIVE").Sort
.SetRange Columns("A:P")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows("DATABASE.xlsm").Activate
ActiveWorkbook.Save
ActiveWindow.Close
Application.CutCopyMode = False
Windows("ENTRY APPLICATION.xlsm").Activate
Sheets("FORM").Select
End Sub
please forgive my complicated explanation, but the thing I am trying to do has already complicated me enough ! so please help. thank you.
my edited code according to the first answer I received from @stringeater. please check it and help me what to adjust next. Im just getting an error now in setwbkDATABAS = Nothing
Sub DATA_BASE_ARCHIVE_FullArchive()
Dim rngNEWROUND As Excel.Range
Dim arrNEWROUND As Variant
Dim wbkDATABASE As Excel.Workbook
Dim rngDataTarget As Excel.Range
Dim rngDataSource As Excel.Range
Dim varData As Variant
Dim rngArchive As Excel.Range
Application.ScreenUpdating = False
Set rngNEWROUND = ThisWorkbook.Sheets("NEWROUND").Range("A1:N2000")
arrNEWROUND = ThisWorkbook.Sheets("NEWROUND").Range("A1:N2000")
Set wbkDATABASE = Workbooks.Open(filename:="E:\DELEGATION APPLICATION SAMPLE\2-2023\DATABASE.xlsm")
Set rngDataTarget = wbkDATABASE.Sheets("FullArchive").Range("A2001")
Set rngDataTarget = rngDataTarget.Resize(UBound(arrNEWROUND, 1), UBound(arrNEWROUND, 2))
rngDataTarget.Value = arrNEWROUND
Set rngDataSource = rngDataTarget.Worksheet.Range("A2001")
varData = rngDataSource.Value
wbkDATABASE.Save
wbkDATABASE.Close
setwbkDATABASE = Nothing '(and Im getting error here)
Set rngArchive = ThisWorkbook.Sheets("ARCHIVE").Range("A1") 'reference range
rngArchive.Value = varData
ThisWorkbook.Worksheets("ARCHIVE").Sort.SortFields.Clear
ThisWorkbook.Worksheets("ARCHIVE").Sort.SortFields.ADD Key:=Columns("L:L"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ThisWorkbook.Worksheets("ARCHIVE").Sort.SortFields.ADD Key:=Columns("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ThisWorkbook.Worksheets("ARCHIVE").Sort
.SetRange Columns("A:P")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
Sheets("FORM").Select
End Sub