LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default How to find last row/column with vba?

Is there a way to tell Excel to just go to the end of the populated cells -
either row or column? I have a number of situations where I know the start,
but not the end of a range. For example, I need to set an entire worksheet
(except the first column) to NumberFormat = "0.0000"

I've tried this:


xlapp.Workbooks(strXlsFile).Worksheets(sn(i)).Rang e("B2").End(xlToRight).Num
berFormat = "0.0000"

but no luck. I also need to insert a formula in a column, but I don't know
how many rows it will have. This works:

xlapp.Workbooks(strXlsFile).Worksheets(sn(i)).Rang e("D2:D76").Formula =
"=STDEV(E2:AH2)"

but I've hardcoded the range. I know it will start at D2, but I don't know
that it will always end at D76. I found this code:

Private Function LastRow() As Long
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
End Function

But I'm not sure if this is the right way to do it. Any suggestions
welcome!

Thanks in advance.


 
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
FInd common data in one column then add number in adjacent column JT Excel Worksheet Functions 3 December 18th 09 10:20 PM
find last row value in column when using MATCH to find column Bouce Excel Worksheet Functions 6 February 6th 08 10:16 PM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
Need Macro to Find Column Heading -- if none, then insert new column Jeff[_43_] Excel Programming 0 December 15th 04 07:08 AM


All times are GMT +1. The time now is 08:04 AM.

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"