ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find last row in workbook sheet & move data to it from another sh (https://www.excelbanter.com/excel-programming/428613-find-last-row-workbook-sheet-move-data-another-sh.html)

Chris Maddogz

Find last row in workbook sheet & move data to it from another sh
 
I have two worksheets within a workbook called Jobs Workbook

The worksheets are named Concrete & Database

Concrete is the active worksheet

I need to archive cell data from Concrete & piggyback it onto the next
available row in Database (currently this worksheet has about 1100 rows of
active data in 30 columns).

Therefore from Concrete ( I would be using a button on it to assign the
macro to) I would like the macro coding to first find the next available row
after the last archived row(call it row n) in Database & using that address
move the following data from Concrete to to the relevant cells in Row n of
Database:

Concrete(E1) to Database(An)
Concrete(B3) to Database(Bn)
Concrete(B1) to Database(Cn)
Concrete(E5) to Database(Gn)
Concrete(B55) to Database(Jn)
Concrete(E2) to Database(Kn)

When this is done I need to go back to the acttive worksheet (Concrete) and
save the workbook.

At a later stage I will be using the found row number n - so I need to know
what to reference it by after this macro has found it

Thanks

Chris

Then save the workbook Jobs

Thank You

Jacob Skaria

Find last row in workbook sheet & move data to it from another sh
 
Please try the below and feedback. Variable lngLastRow will have the last row

Sub test()
Dim lngLastRow As Long

With ActiveWorkbook.Sheets("Database")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
..Range("A" & lngLastRow) = ActiveSheet.Range("E1")
..Range("B" & lngLastRow) = ActiveSheet.Range("B3")
..Range("C" & lngLastRow) = ActiveSheet.Range("B1")
..Range("G" & lngLastRow) = ActiveSheet.Range("E5")
..Range("J" & lngLastRow) = ActiveSheet.Range("B55")
..Range("K" & lngLastRow) = ActiveSheet.Range("E2")
End With

End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Chris Maddogz" wrote:

I have two worksheets within a workbook called Jobs Workbook

The worksheets are named Concrete & Database

Concrete is the active worksheet

I need to archive cell data from Concrete & piggyback it onto the next
available row in Database (currently this worksheet has about 1100 rows of
active data in 30 columns).

Therefore from Concrete ( I would be using a button on it to assign the
macro to) I would like the macro coding to first find the next available row
after the last archived row(call it row n) in Database & using that address
move the following data from Concrete to to the relevant cells in Row n of
Database:

Concrete(E1) to Database(An)
Concrete(B3) to Database(Bn)
Concrete(B1) to Database(Cn)
Concrete(E5) to Database(Gn)
Concrete(B55) to Database(Jn)
Concrete(E2) to Database(Kn)

When this is done I need to go back to the acttive worksheet (Concrete) and
save the workbook.

At a later stage I will be using the found row number n - so I need to know
what to reference it by after this macro has found it

Thanks

Chris

Then save the workbook Jobs

Thank You



All times are GMT +1. The time now is 12:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com