Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default C# programming - Getting number of last non-blank cell (column) in a row.

I need to get the column number of the last non-blank cell in a row. I
am using the Excel Com object in a .NET app to get this done

I have something like this
Range rg = xSheet.get_Range("A1","A1"); // xSheet is the worksheet
object.
int lastColumnNumber = rg.Cells.....

I am not sure what the method call to do or the steps to follow.
Any help is appreciated,
- K.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default C# programming - Getting number of last non-blank cell (column)in a row.

Not sure how you translate this into C# but in VBA it would be

lastColumnNumber = xsheet.cells(1,columns.count).end(xltoleft).column

Hope this helps
Rowan

Paddy wrote:
I need to get the column number of the last non-blank cell in a row. I
am using the Excel Com object in a .NET app to get this done

I have something like this
Range rg = xSheet.get_Range("A1","A1"); // xSheet is the worksheet
object.
int lastColumnNumber = rg.Cells.....

I am not sure what the method call to do or the steps to follow.
Any help is appreciated,
- K.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default C# programming - Getting number of last non-blank cell (column) in a row.

Thanks but I was specifically looking for C# way to do this. The COM
API that is exposed to Visual Studio (i am referencing the Excel 9/10
COM object in my solution) does not explain the API nor the arguments
that are used.

So, I actually have xsheet.Cells but it is a property and I don't see
the sequence of method calls from there to get the last non-blank
column number.

- K


Rowan Drummond wrote:
Not sure how you translate this into C# but in VBA it would be

lastColumnNumber = xsheet.cells(1,columns.count).end(xltoleft).column

Hope this helps
Rowan

Paddy wrote:
I need to get the column number of the last non-blank cell in a row. I
am using the Excel Com object in a .NET app to get this done

I have something like this
Range rg = xSheet.get_Range("A1","A1"); // xSheet is the worksheet
object.
int lastColumnNumber = rg.Cells.....

I am not sure what the method call to do or the steps to follow.
Any help is appreciated,
- K.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
row number of last non-blank cell Bill Brehm Excel Worksheet Functions 12 January 16th 10 04:31 PM
macro that will paste a number in first blank cell of a column asebes Excel Discussion (Misc queries) 1 December 28th 09 05:34 PM
SUM values in this column F only if cell is blank in column Q...HE Lisa Excel Discussion (Misc queries) 3 March 1st 07 03:22 PM
how to calculate the number of non blank cells from any column? Mahesh Excel Worksheet Functions 2 August 8th 06 01:14 PM
Number of different items in an entire column without knowing if some of the cells are blank [email protected] Excel Programming 10 March 20th 05 05:31 PM


All times are GMT +1. The time now is 03:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"