View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default get_End question

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



"Ollie Purkiss" wrote:

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_numbe r, 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