-
Text1 to excel
Hello everybody,
I need your help again on this code:
Code:
Dim xlExcel As New Excel.Application
xlExcel.ActiveWorkbook.Sheets(1).Cells(2, 4).Value = Text1.Text
xlExcel.Application.DisplayAlerts = False
xlExcel.ActiveWorkbook.SaveAs "C:\Documents and Settings\test.xls"
xlExcel.ActiveWorkbook.Close
xlExcel.Quit
Set xlExcel = Nothing
I would like the code to found in column 4 the last value insert, and right down the new value in the first empty cell just under.
How can I do this please?
Thanks again.
-
Re: Text1 to excel
I don't understand. That looks like it changes (2,4) to Text1
-
Re: Text1 to excel
Yes, you are right,
But now, I want to change it to the first cell that is empty in column 4, starting from line 2, going down.
-
Re: Text1 to excel
You can use either of these technioques to determine the last used row/cell. It best to go from the bottom up as if you go from the top down it may not be the last used cell as it only looks at empty cells.
Code:
Dim oRange As Range
Set oRange = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell)
MsgBox oRange.Address
'Or
MsgBox Range("D65536").End(xlUp).Row + 1