$Excel Macro - Finding the last row of data and go down one row.... I am new to
ID: 3561289 • Letter: #
Question
$Excel Macro - Finding the last row of data and go down one row....
I am new to VBA and have no programming experience or degrees. I need help with finding the last row of data and go down one row to copy data from another workbook. Everything I tried doesn't work. Here's my macro:
Sub Activity_Import()
'
' Activity_Import Macro
'Opens the Individual Tracker for a specific planner and selects the range of text from A1..O1400
ChDir "T:stats"
Workbooks.Open Filename:="T:StatsIndividual Tracker Ed 2014.xlsm"
Range("A6:O1400").Select
' Range to be copied is selected in the Individual Tracker Planner spreadsheet
Application.DisplayAlerts = False
Selection.Copy
Switches to the Individual Tracker for Head Office workbook, puts the cursor in Cell A6
' and issues the Paste Special command and saves the Head Office workbook.
Windows("Individual Tracker Head Office.xlsm").Activate
Sheets("Waterloo Master Activ").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Range("A6").Select
ActiveWorkbook.Save
Windows("Individual Tracker Ed 2014.xlsm").Activate
ActiveWorkbook.Close
Sheets("Waterloo Master Activ").Select
LastRow = Cells.Find(What:="*", After:=[A6], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
MsgBox "End of Macro"
End Sub
Can anyone help? Thanks.
Explanation / Answer
$^#67357Hi,
source workbook (wb1) is closed and target workbook is open (wb2)
try this...
(make a copy before)
Sub qqaazz()
Dim wb2 As Workbook '<< target workbook
Set wb2 = ThisWorkbook 'open
Dim wb1 As Workbook ' << source wb
Set wb1 = Workbooks.Open("T:StatsIndividual Tracker Ed4.xlsm")
Set ws1 = wb1.Sheets("Activity Database")
ws1.Range("A6").CurrentRegion.Copy
LRow = wb2.Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row
wb2.Worksheets(1).Range("A" & LRow + 1).PasteSpecial xlPasteAll
Application.CutCopyMode = False
wb1.Close False
wb2.Save
End Sub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.