Get an Excel Column

  • Thread starter Thread starter Robert Flovita
  • Start date Start date
R

Robert Flovita

Hi ,
I want to find last used cell in a column .
(for example "c" or 3 )
can count used range of a column .
set a range to used range of a column .
thank you .
 
Hi Robert,

This Excel macro does it for me:

Function LastCellUsedOnRight (ByVal uiRow As Integer, ByVal uiCol As
Integer) As Integer
Dim WS As Worksheet
Set WS = ActiveSheet

For uiCol = uiCol + 1 To 10000
'If WS.Cells(uiRow, uiCol).Text = "" Then 'Can't use - sometimes
fails.
If WS.Cells(uiRow, uiCol).Formula = "" Then
Exit For
End If
Next
LastCellUsedOnRight = uiCol - 1
End Function

I'll leave it to you to figure out how to:

1) Add a reference to Excel in your project.
2) Add the appropriate import to your code.
3) Create an instance of Excel.
4) Open the spreadsheet.
5) Do what the function does.

Good luck,
Fergus
 
Back
Top