ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   get_End question (https://www.excelbanter.com/excel-programming/435327-get_end-question.html)

Ollie Purkiss

get_End question
 
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


Patrick Molloy[_2_]

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



All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com