PDA

View Full Version : Copying last value of a column



afzalw
07-29-2012, 10:46 AM
I got this code that copies values from a cell B5 in a sheet named "Distress Data" and paste it into shdest.cells

Set rDest = shDest.Cells(shDest.Rows.Count, 2).End(xlUp).Offset(1, 0)
rDest.Value = wbSource.Sheets("Distress Data").Range("B5").Value

My question is How can I change the second line to copy the last value in the column B.

afzalw
07-29-2012, 01:20 PM
I tried using this code but it gives the number of row of the last value i column

Set rDest = shDest.Cells(shDest.Rows.Count, 2).End(xlUp).Offset(1, 0)
rDest.Value = wbSource.Sheets("Distress Data").Range("B" & Rows.Count).End(xlUp).Row

patel
07-29-2012, 01:43 PM
I don't understand, explain your goal without proposing code

CatDaddy
07-30-2012, 09:06 AM
Set rDest = shDest.Cells(shDest.Rows.Count, 2).End(xlUp).Offset(1, 0)
rDest.Value = wbSource.Sheets("Distress Data").Range("B" & Rows.Count).End(xlUp).Value