0

Hi can anyone help me in getting the desired output?

I need to retrieve the last row values from an excel and copy the data from the cells onto separate worksheet into two different columns. Best Regards

pnuts
  • 58,317
  • 11
  • 87
  • 139
satya
  • 313
  • 1
  • 7
  • 15
  • Check this URL to get last row: http://stackoverflow.com/questions/11169445/error-finding-last-used-cell-in-vba. And you can search how to copy and paster the rows on google. – Paresh J Nov 05 '14 at 15:16
  • Hi Paresh, i have managed to get the Last Row however when i am struggling to retrieve two columns information from that row. for example if my last row is 21, i need the values from E21 and H21 copied on to different Spreadsheet. Any help appreciated. – satya Nov 05 '14 at 16:33
  • Is it like you always want to retrieve data from last cell and last cell + 2? As in your eg shows E21 and H21. – Paresh J Nov 06 '14 at 05:16
  • Yes, basically if my Last row is say 11 then i need data from E11 & H11 and say if my Last row is 19 then i need to retrieve the data from E19 & H19 – satya Nov 06 '14 at 11:09

1 Answers1

1

Once you got the LastRow of specific column, you can use the following code to get the value of cells you want:

For Eg: If A is the specific column and variable LastRow contains the row count then,

strA = Range("A" & LastRow).Value 
strB = Range("A" & LastRow).Offset(0, 3).Value

Where, If LastRow = 5, strA contains the value of cell A5 and using offset strB contains the value of cell D5

Paresh J
  • 2,401
  • 3
  • 24
  • 31