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

They are both Longs, so you can't use like that, as it is expecting
string/long. Try this

For i = 1 To sn.Count
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Cells(1).EntireRow.HorizontalAlignment = xlCenter
.Cells(1).EntireRow.Font.Bold = True
.Range(.Range("C2") & .Cells(LastRow, LastColumn)).NumberFormat =
"0.0000"
.Range("D2:D" & LastRow).Formula = "=STDEV(E2:AH2)"
.Columns.AutoFit
End With
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"deko" wrote in message
m...
It is not looping so it would be fast. Probably not as fast as

SpecialCells,
but as Ron points out, SpecialCells will give a wrong answer in certain
circumstances.


I will definitely use those functions - from what I've read they are
preferred over SpecialCells for the reasons Ron described.

Still, it's using the cell number to define the last column that's got me
confused. For example, how do I set the NumberFormat below?

Here is my loop:

For i = 1 To sn.Count
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Cells(1).EntireRow.HorizontalAlignment = xlCenter
.Cells(1).EntireRow.Font.Bold = True
.Range("C2:" & LastColumn & LastRow).Cells.NumberFormat = "0.0000"
.Range("D2:D" & LastRow).Formula = "=STDEV(E2:AH2)"
.Columns.AutoFit
End With
Next i

Clearly, "LastColumn & LastRow" fails. But how else do I define this

range?




 
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 07:41 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"