get_End question

  • Thread starter Thread starter Ollie Purkiss
  • Start date Start date
O

Ollie Purkiss

Hello,

I'm using the get_End function for finding a row of used cells (using VSTO
3.0 and C#). My code works fine if there are two or more cells next to each
other with something in them, but if only the first cell has something in it,
then I get the whole row. Is that expected behaviour for get_End, or am I
doing something wrong?

My code:
Range first_cell = Globals.SheetBuyerHistory.Cells.get_Item(row_number, 1)
as Range;
Range last_cell = first_cell.get_End(XlDirection.xlToRight);
Range used_row = Globals.SheetBuyerHistory.Range[first_cell, last_cell] as
Range;

Cheers,

Ollie
 
use column count to get the last colun then use End(xltoleft)
this will get the last column used in that row
 
Back
Top