I am recording a macro which will update formulas in a worksheet based on a new table which is pasted into a different worksheet monthly. I am trying to reference the last cell containing text in a column. I have tried using Ctrl downarrow while recording the macro, but when I look at the code, a cell reference is used. To test out the macro I inserted more rows in the main sheet and it is not referencing the last cell, regardless of how many rows there are. How can I get excel to "go to the last entry in this column" and use that cell as a reference on another sheet. Each month I want to run the macro so it will automatically use values from the last row, whatever the row number.
Reference Last Cell In Column
-
-
-
Re: Reference Last Cell In Column
try somethng like this
CodeSub test() Dim x As Range Worksheets("sheet1").Activate Set x = Cells(Rows.Count, "a").End(xlUp) MsgBox x.Address Worksheets("sheet2").Activate Cells(x.Row, "a") = "venkat" End Sub
this is only a trivial example. you have to modify to suit you.
-
Re: Reference Last Cell In Column
Quote from Barrie Davidson;303913For Excel 2010, last cell is not 65536 so to make sure your code runs well on any Excel version I'd go with:
[INDENT]Where 1 specifies Sheet index (and can be replaced by Sheet name enclosed in double quotes) and "B" specifies the Column you intend to find last used cell.[/INDENT]
tears
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!