chingg1011
New Member
- Joined
- Oct 8, 2021
- Messages
- 18
- Office Version
- 365
- 2010
- Platform
- Windows
- Mobile
Hi VBA Expert,
I am meeting a difficult to perform "Daily Run data"
The background is that I want to copy daily data onto my separate worksheet, but need to keep old data (accumulated data 1 Jan 24, 2 Jan 24, 3 Jan 24....etc) I have recorded a marco as below:
My problem is when I try to click "Ctrl + Arrow down" A41 and drop one more row A42 for 3 Jan, 4 Jan..etc. The data to reach is always at Row A42, It is failure to copy new data after 2 Jan ......etc
Can any expert edit my code to make it successful ?
Thanks
Dennis
Below is my marco and screen shot for easy ref
========================================================================================================================================
Sub Daily_Run()
'
' Daily_Run Macro
'
'
Application.CutCopyMode = False
Selection.Copy
Workbooks.Open Filename:= _
"https://hkwbl.sharepoint.com/teams/...20240331/Data/LOAN_Table_2024-01-25T1001.xlsx"
Range("A1:AX12909").Select
Range("A2").Activate
Application.CutCopyMode = False
Selection.AutoFilter
Selection.End(xlUp).Select
Range("Z1").Select
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("Z1:Z12909"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
Selection.End(xlToLeft).Select
Range("A2:AX21").Select
Selection.Copy
ActiveWindow.ActivateNext
Sheets("Loan table top 20").Select
Range("A2").Select
Selection.End(xlDown).Select
Range("A42").Select
ActiveSheet.Paste
ActiveWindow.ActivateNext
ActiveWindow.Close
Sheets("macro").Select
ActiveWorkbook.Save
End Sub
==========================================================================================================================================
I am meeting a difficult to perform "Daily Run data"
The background is that I want to copy daily data onto my separate worksheet, but need to keep old data (accumulated data 1 Jan 24, 2 Jan 24, 3 Jan 24....etc) I have recorded a marco as below:
My problem is when I try to click "Ctrl + Arrow down" A41 and drop one more row A42 for 3 Jan, 4 Jan..etc. The data to reach is always at Row A42, It is failure to copy new data after 2 Jan ......etc
Can any expert edit my code to make it successful ?
Thanks
Dennis
Below is my marco and screen shot for easy ref
========================================================================================================================================
Sub Daily_Run()
'
' Daily_Run Macro
'
'
Application.CutCopyMode = False
Selection.Copy
Workbooks.Open Filename:= _
"https://hkwbl.sharepoint.com/teams/...20240331/Data/LOAN_Table_2024-01-25T1001.xlsx"
Range("A1:AX12909").Select
Range("A2").Activate
Application.CutCopyMode = False
Selection.AutoFilter
Selection.End(xlUp).Select
Range("Z1").Select
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("Z1:Z12909"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
Selection.End(xlToLeft).Select
Range("A2:AX21").Select
Selection.Copy
ActiveWindow.ActivateNext
Sheets("Loan table top 20").Select
Range("A2").Select
Selection.End(xlDown).Select
Range("A42").Select
ActiveSheet.Paste
ActiveWindow.ActivateNext
ActiveWindow.Close
Sheets("macro").Select
ActiveWorkbook.Save
End Sub
==========================================================================================================================================