tags:

views:

43

answers:

1

i am populating the row from The Database using VBA I had More than 50 Column in the Excel sheet in that i wants to find last column address to display the total of the entire data's total is there is any possible please guide me thanks in advance

A: 

Code from http://www.ozgrid.com/VBA/ExcelRanges.htm . You'll find there other useful subs for finding "last" things in Excel, and several caveats.

Sub FindLastColumn()
Dim LastColumn As Integer
If WorksheetFunction.CountA(Cells) > 0 Then
    'Search for any entry, by searching backwards by Columns.'
     LastColumn = Cells.Find(What:="*", After:=[A1], _
                       SearchOrder:=xlByColumns, _
                   SearchDirection:=xlPrevious).Column
               MsgBox LastColumn
End If 
End Sub
belisarius
Thank you for your reply i try this code it work but this code return the last used column count that is if the last used column is 24 cell from the left means it return the cell count but i need the exact Cell Range (For example :if last used column range is T4 then i need the exact T4 as a result).now i am using this code Range("IV4").End(xlToLeft).Select
raam