-
WSMichael Evans
AskWoody LoungerThanks Hans and Rudi
Having to put the code in each sheet would be a bit of a drag, but Rudi’s code works beautifully.
Will someone explain to me what the (ByVal Sh As Object, ByVal Target As Range) does?
-
WSMichael Evans
AskWoody LoungerSorry people.
My attachment did not have a Date Accessed in cell A2, this was because my original development Workbook is at work and I will not have access to it for two weeks, so I had to start a new one and I forgot to put a date in A2, in my original book this is done with a workbook open macro.
Apologies. This attachment is correct
-
WSMichael Evans
AskWoody LoungerThanks for the help everyone. I’ll deal with the points raised in turn.
The code is exactly as I put it in post 683787, which I believe is a ‘before save’. Also the macro is partly executing when I save as I explained in post 683809, it is putting the date into the cell to the right of the selected cell, it just is not moving the selected cell to the end of Column A
The code is in the ‘ThisWorkbook’ object; not having in there was my early error but Hans put me right on that in post 683772.
Legare, I am not clear what the ‘the module behind the ThisWorkbook object’ is, I double clicked on ThisWorkbook in the Project Window and pasted the code in there, if I try to add a module whilst in ThisWorkbook VBA adds a module into the Modules, not into theObjects/ThisWorkbook.
I think adding user information is a good idea too.
-
WSMichael Evans
AskWoody LoungerThanks for that Steve.
I still find it puzzling that the selected cell does not change when the code is run as a WorkbookBeforeSave macro but it works perfectly as an ordinary macro.
Incidentally is it possible to step through a WorkbookBeforeSave macro?
-
WSMichael Evans
AskWoody LoungerThis is to be a log of accesses and saves of this workbook, people will rarely be in the UsageLog sheet when they save so I made the macro go to the UsageLog sheet and the appropriate cell to enter the save date and time.
The offset is correct, the idea is to go to the last used cell in Column A, which is the list of accesses and contains today’s date from a workbook open macro, then to update Column B, which contains the Date Saved data, with the date and time of saving, overwriting any previous saves made today.
Yes it is in ThisWorkbook and it works in that it writes the date and time in the cell to the right of whatever cell is selected at the time the save is made (I have been in sheet UsageLog during all the testing, just selecting different cells before I save), it just does not move the selection to the last cell of Column A before doing the writing.
-
WSMichael Evans
AskWoody LoungerThis code
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo ErrorHandlerActiveWorkbook.Sheets(“UsageLog”).Select
MsgBox (“UsageLog Sheet Exists”)‘goto last used cell in col A, should be today’s date, inserted when the workbook was opened
Range(“A65536”).End(xlUp).Select
MsgBox (“Cell (A, Last) should be selected”)
ActiveCell.Offset(0, 1).Value = Date & ” ” & Time ‘overwrite any previous savesErrorHandler:
End Sub
Does not work, the selected cell remains whereever it was before the workbook is saved, but when the same code is run as an normal macro all proceeds as intended with the selected cell going to the end of Column A
-
WSMichael Evans
AskWoody LoungerThank you Hans
-
WSMichael Evans
AskWoody LoungerThanks to you all for your efforts. However I have put both Jan’s and Hans’s code into a module without success. So I tried the following
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox (“Saving File”)
End SubI put this in a code module in my workbook, then saved the file but my message box did not appear, is there somthing more I need to do?
TIA
-
WSMichael Evans
AskWoody LoungerThank you Hans
Only being able to access the info when the file is closed is a very useful feature.
I am not familiar with user defined functions, am I doing this right, I copied the function into a module in my workbook then in a cell in my workbook I typed:
=GetProperty(ActiveWorkbook, 4)
and I get a type mismatch error (same when I put the full path instead of ActiveWorkbook)
-
WSMichael Evans
AskWoody LoungerThank you Hans
I will check it out.
-
WSMichael Evans
AskWoody LoungerThank you Jan and Andrew
-
WSMichael Evans
AskWoody LoungerWorks perfectly
Many thanks Hans
-
WSMichael Evans
AskWoody LoungerThank you John.
Seems like Microsoft doing what it does best.
-
WSMichael Evans
AskWoody LoungerThats great.
Thanks yet again Hans
-
WSMichael Evans
AskWoody LoungerPlaying around with the problem some more, I think the macro is working from the size of the original chart, which may not be identical for all my charts. Is it possible to specify the sizing to be 5 columns and 20 row, aligning with the gridlines in the new sheet.
Thanks.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
YouTube Ad Blocker Blocker
by
bbearren
1 hour, 42 minutes ago -
Obscure historical facts about Windows
by
Cybertooth
3 hours, 10 minutes ago -
Microsoft Backup
by
Linda2019
3 hours, 40 minutes ago -
What is the best notepad++ version for W7?
by
Picky
6 hours, 3 minutes ago -
What are right steps to move MS 365 Office+OneDrive files from PC to iMac?
by
glnz
13 hours, 3 minutes ago -
How to move existing MS 365 Office with OneDrive files from PC to new iMac
by
glnz
13 hours, 5 minutes ago -
How to move MS 365 files (some on OneDrive) from PC to iMac
by
glnz
1 day, 8 hours ago -
Microsoft adding Quick Machine Recovery to Windows 11
by
Alex5723
1 day, 8 hours ago -
Microsoft vs Passwords
by
Alex5723
16 hours, 21 minutes ago -
Windows 11 Insider Preview build 26200.5516 released to DEV
by
joep517
1 day, 12 hours ago -
Windows 11 Insider Preview build 26120.3653 (24H2) released to BETA
by
joep517
1 day, 12 hours ago -
Two March KB5053606 updates?
by
Adam
1 day, 5 hours ago -
MS Edge Not Updating to v134.0.3124.95 (rel. 27-Mar-2025)
by
lmacri
1 day, 6 hours ago -
Intel® Graphics/Sound Driver updates for 7th-10th Gen Intel® Core™ Processor
by
Alex5723
1 day, 8 hours ago -
Is there a comprehensve way to tranfer ALL current Edge Settings into a new Edge
by
Tex265
1 day, 7 hours ago -
Transferring ALL info/settings from current Firefox to new computer Firefox
by
Tex265
1 day, 6 hours ago -
DOGE Wants to Replace SSA 60 Million Line COBOL Codebase in Months
by
EyesOnWindows
1 hour, 54 minutes ago -
KB5051989 Usb printer Post Ipp
by
licencesti
2 days ago -
Removing bypassnro
by
Susan Bradley
7 hours, 58 minutes ago -
Up to 30 seconds to show “Recent Topics”
by
PL1
1 day, 4 hours ago -
Sound changes after upgrade from W11 23H2
by
WStaylorpsepa
5 hours, 32 minutes ago -
Windows bug blocks BIOS updates for Lenovo ThinkPad laptops
by
Alex5723
2 days, 9 hours ago -
O&O Software – ‘World Backup Day’ Sale
by
unbob
2 days, 5 hours ago -
Still version 23H2?
by
WSbxcfilm
2 days, 10 hours ago -
Ubuntu 25.04 (Plucky Puffin) Beta released
by
Alex5723
2 days, 16 hours ago -
How to install App Store apps on an external SSD
by
Alex5723
2 days, 16 hours ago -
Where is Windows going?
by
Susan Bradley
8 hours, 12 minutes ago -
Installing Feature Update Windows 11 24H2
by
geekdom
3 days, 10 hours ago -
Windows 11 Insider Preview build 27823 released to Canary
by
joep517
3 days, 10 hours ago -
Windows 11 Hotpatch
by
Hackmuss
2 days, 18 hours ago
Recent blog posts
- Removing bypassnro
- Where is Windows going?
- System Guard service error still won’t be fixed
- Third party add ins reminder
- MS-DEFCON 4: Mixed bag for March
- Classic and Extended Control Panel — no need to say goodbye
- Things you can do in 2025 that you couldn’t do in 2024
- Revisiting Windows 11’s File Explorer
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.