D
deko
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)).Range("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)).Range("D276").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.
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)).Range("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)).Range("D276").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.