roberttaekim
New Member
- Joined
- Jan 22, 2021
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi excel experts. Can someone please help with instead of copying a defined range 1300 rows below, can you help with doing a last row of data based on the last row of data in column A?
Really appreciate any help.
Really appreciate any help.
VBA Code:
[/
Sub CopyPending()
'
' CopyPending Macro
'
Dim NmStr As String 'ActiveWorkbook
Dim FDate As String 'Lookup Value
Dim WB As Workbook 'the workbook to open
NmStr = ActiveWorkbook.Name
Windows(NmStr).Activate
'Selects the value in A6 to do a search in the workbook to open
FDate = ActiveWorkbook.Sheets("Recon").Range("A6").Value
'Open workbook based on address in B5
Set WB = Workbooks.Open(Range("B5").Value)
'Find the value of FDate in the newly opened workbook and copy range 1 row below from active cell to column K down to the 1300 row below
Cells.Find(What:=FDate, After:=ActiveCell, LookIn:= _
xlFormulas2, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Range("A1:K1300").Select
Selection.Copy
'Activate recon workbook
Windows(NmStr).Activate
ActiveWorkbook.Sheets("OpsReport_LCs_PendingFees").Select
'Find Fdate value in the recon workbook and paste it 1 row below
Cells.Find(What:=FDate, After:=ActiveCell, _
LookIn:=xlFormulas2, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RECON").Select
Application.CutCopyMode = False
WB.Close savechanges:=False
'
End Sub
]