Insert date in next empty cell

Mötley

Board Regular
Joined
Aug 3, 2011
Messages
93
Hello,

how do I modify this code so that it inserts new date in next available cell?

Code:
Sub SetDate()
'Set cell D2 to the current date
ActiveSheet.Range("AS23").Value = Date
End Sub


For example, I add todays date in cell AS23, tomorrow I add new date and it will appear on AT23 and so on
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
What about this

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Macro1()<br><SPAN style="color:#007F00">'using xlLastcell and offset 1 column</SPAN><br>    ActiveCell.SpecialCells(xlLastCell).Select<br>    ActiveCell.Offset(0, 1) = <SPAN style="color:#00007F">Date</SPAN><br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Thanks, that works great, just like I wanted! But is it possible that I can decide what cell I want to fill? Like that AS23 like I said in previous message?
 
Upvote 0
You could use an inputbox so you get a prompt first and then you type in the cell reference (Like using the goto command) and then it adds the date, is that what you mean.



As you mentiond the last cell.

Do you mean the last cell in a particular row, like 23 and the next available column?
 
Upvote 0
Umm... I mean like this,

I attach the code into commandbutton, it adds specific date into cell, let's say A23, then tomorrow B24, then day after C24 etc etc
 
Upvote 0
How are you looking to specify which cell as you have indicated row 23 then row 24?
 
Upvote 0
Try this then.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> mcrGoTo()<br>Range("IV23").Select<br>ActiveCell.End(xlToLeft).Offset(0, 1) = <SPAN style="color:#00007F">Date</SPAN><br>Range("A2").Select<br><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
It works but why i cannot change the cell where to put date? It always puts it in AI23

EDIT: Nevermind :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top