ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   logging excel events? (https://www.excelbanter.com/excel-programming/271511-re-logging-excel-events.html)

John Wilson

logging excel events?
 
Ross,

I use something that I gleaned off of j-walk's site.
Should do exactly what you want.

Open ThisWorkbook.path & "\Logs\PT.log" For Append As #1
Print #1, Now, Application.UserName, "Added"
Close #1

The above will log the Date/Time, UserName and the comment "Added"
to a file named PT.log in a subdirectory of the one that the workbook
is saved in named logs (modify to suit your needs).
The beauty of this is that if the file doesn't exist, it will be created
and
if it does, it will just append to it (the directory des need to
pre-exist).

John

Ross wrote:

hi there,

could someone suggest some code which would log events into a text
file when something happens in excel?

for example, comparing items in a column representing quantity of a
product about to be delivered to the same row in another column
representing storage space available, to log the time and the two
quantities to a text file when the about to be delivered quantity
exceeds storage space.

Logging the items into a different excel workbook (i.e. log_date.xls)
would be OK, too, but not a different worksheet in the same workbook
because I don't want to be re-saving the primary workbook with a bunch
of data log in it.

thanks again. this Group is an amazing help!

Ross




All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com