I want a macro in Excel to do the following: When ctrl-d is pressed (and some cell X is selected), today's date is inserted into that cell (in form mm/dd/yy).
Record a macro with the Ctrl+D shortcut then stop without doing anything. Now open the Macro window again, select the macro you just recorded and click Edit. You should see a code editor, into which you can paste the above code, like this:
Code:
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 09/12/2011 by Ben Ryves
'
ActiveCell.FormulaR1C1 = Date
'
End Sub
It would put it in the active (i.e. selected) cell. Ctrl+; (and Ctrl+Shift+; for the time) are built-in shortcuts for Excel, not macros per se.
Since you know a lot about VB, perhaps you can help me with this; I have a spreadsheet for attendance. Column A are the names, and the rest are whether or not the person is here. Can I use macros to (assuming the first cell of the old column is selected):
1-insert a new column with the same conditional formatting as the previous row
2- insert today's date (mm/dd/yy)
3- select all the previous columns (from the old to A, not the new one) and set their format to locked
4- lock the sheet with some password
1-insert a new column with the same conditional formatting as the previous row
2- insert today's date (mm/dd/yy)
3- select all the previous columns (from the old to A, not the new one) and set their format to locked
4- lock the sheet with some password
I'm afraid I won't have too much time to look at this in the short term (and am not desperately familiar with Excel) but you should be able to do most of the above by recording a macro, at which point I'm sure someone here can help with any hand tweaking.
- JPfowl
- Member (Posts: 136)
- 08 Dec 2011 11:57:05 pm
- Last edited by JPfowl on 09 Dec 2011 12:06:46 am; edited 1 time in total
I am starting to understand VB, so maybe I just need help with a few parts. Here's the first one. Say I have cell X selected, what would the code be for:
1- the previous range from 2-50
2- the target range from 2-50
1- the previous range from 2-50
2- the target range from 2-50
That's a good start; if you need specific help with any of the built-in objects, properties or functions then MSDN has a lot of information.
I have given up that Idea for now, but would like these macros.
1- Ctrl+Q protects all columns to right of selected cell
2- Ctrl+w unprotects all
1- Ctrl+Q protects all columns to right of selected cell
2- Ctrl+w unprotects all
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement