0

I have a table which some particular content I want to copy into new Excel file. I have almost managed to achieve this. I have used following snippet for selection of data of my interest

Range(Range("A3"), Range("H3").End(xlDown))

This works fine for columns which have complete data. However, this does not work for columns which are mostly sparse. I am sure about last row of this column, which is Range("H3").End(xlDown) but I need somehow to increment H to M so the row index is same.

I looked in this topic VBA: Selecting range by variables, nevertheless I was not able to utilize this solution (I am using VBA for one day).

Can you give me some advice about this, please?

I am not sure, if I have described my problem well. If it is not clear, I could try to do it better.

braX
  • 11,506
  • 5
  • 20
  • 33
  • You can use a variable row like this: `Range("A" & lRow)` – braX Feb 04 '20 at 08:23
  • You can use a variable row like this :Range(Cells(1, 1).Address(), Cells(lastRow, lastColumn).Address()).Select – Malakiya sanjay Feb 04 '20 at 08:24
  • Does this answer your question? [Error in finding last used cell in Excel with VBA](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba) – aucuparia Feb 04 '20 at 08:44
  • braX's solution works for me. Thank you all for your help. – Humphrey Appleby Feb 04 '20 at 08:44
  • This is a very common situation, already answered here: https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba/11169920#11169920 (and in several other places!) but `Range(Range("A3"), Cells(Rows.Count, 8).End(xlUp))` should work for you. – aucuparia Feb 04 '20 at 08:45

0 Answers0