Excel 2003 macro: log contents of selected cell, clear cell

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

raydancer

Thread Starter
Joined
Apr 14, 2013
Messages
1
I'm attempting to write my first macro for an Excel 2003 workbook. I'm not completely code illiterate (I've got moderate skills with AutoLISP), but I'm new to VBA and am not yet an Excel power user, so please be gentle.

The macro I want to write will:

  • check that the selected cell's content is underlined before proceeding
  • copy the content of the currently selected cell into an external plain text .log file
  • .log file lines should be: year/month/day - time - username - cell contents
  • .log file names will probably need to be generated
  • clear the cell's content and formatting (particularly underline and text/background color)
Here's what I have so far:

Code:
Sub Unpost()
If Selection.Font.Underline = True
    Then Selection.ClearFormats And Selection.Clearcontents
    Else
        If MsgBox("The selected cell is not underlined...are you sure?", vbOkCancel) = vbOk
            Then Selection.ClearFormats And Selection.Clearcontents
            Else Exit Sub
        End If
End If
End Sub
If I've written it correctly, it should currently do everything except log the cell contents. This, from what I've seen, is going to be the trickier part. I intend to use this macro 50+ times per weekday, so at some point the .log files will get too long to be useful, so I assume it will need to automatically create new logs (perhaps "year-month.log"). I've seen some useful info about appending to an external log here and here, but I'm not sure how to go about putting it into my code, and have no idea how to generate and name new log files.

Any help or ideas you could give would be greatly appreciated.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top