Requirement:
The user's macro is supposed to put in a current date in chosen cell when the user presses a button.
But only in one column this action can be allowed. Column starting from cell B7 and down to infinity.
And date should stay what it was when file is open another day.
This is the macro the user is using:
Private Sub Date1_Click() ActiveCell.Offset(0, 0).Range("A1").Select TIME1 = Date ActiveCell = TIME1 ActiveCell.Select Selection.NumberFormat = "dd/mm/yyyy" ActiveWorkbook.Save End Sub
When the user puts Range("B7:B400"), date appears not in chosen cell.
Solution:
Private Sub Date1_Click() With ActiveCell If .Column = 2 And .Row > 6 Then .Value = Date .NumberFormat = "dd/mm/yyyy" ActiveWorkbook.Save End If End With End Sub
Obtained from the OzGrid Help Forum.
Solution provided by Stephen R.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to set up a macro: if cell contains background color except yellow, disable "wrap text" |
How to create a macro to display names not row numbers |
How to set up an autofill macro |
How to use a macro to clear cells in range with condition for each row |
How to add a password to a macro |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.