copying from a variable last row

kir

New Member
Joined
May 25, 2005
Messages
6
Hello

I want to transfer data in the last colom of a worksheet to another worksheet.
After that I want to delete that last row, and then transfer the data from the new last row into the other worksheet.

example:

When the last row with data is K, then I want to copy K5 to a cell in another sheet. But when the last row with data is P, then I want to copy P5 to that other sheet. After the copying, the data of the last should be deleted.

So, initially the last row was K, but after copyying the data, and then deleting K, the last row becomes J.

Can anybody help me with this?

Thanks.

Kir
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Kir

You seem to be mixing up columns and rows. Is the data always in row 5, but the column is variable??? If so and you want to find the last column of data in row 5 then

lastcoll = range("iv5").end(xltoleft).column
will give the column number of the last column in row5 with data.

If you want to copy that data elsewhere then

sheets("othersheet").range("youroutputrange") = cells(5,lastcoll).value
cells(5,lastcoll).clearcontents

will copy the value to another place, then clear the cell.

You could put that into a loop until you want to stop.

HTH

Tony
 
Upvote 0

Forum statistics

Threads
1,215,378
Messages
6,124,601
Members
449,173
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top