Results 1 to 3 of 3

Thread: Excel VBA... Quick Add Note Macro

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Posts
    74

    Question Excel VBA... Quick Add Note Macro

    Problem: the note section of a flat database is located about 17 columns from the name of the item being looked up. The notes sometimes get placed in the wrong file and to mitigate this I need something that will be as close to fool proof as possible.

    I was thinking something simple that would take the selected cell (the item being looked up)(any cell in column C in the picture below) and through the macro a box or form would appear asking you to add a note to the file... the trick is that I do not want to erase any of the notes currently in the notes cell for that particular record; also a date stamp of when the note was entered would be much appreciated as everybody seems to use their own formatting and it gets really annoying.

    Example:
    Name:  delete200.jpg
Views: 374
Size:  32.8 KB

    Thanks for your help.
    Last edited by IGPOD; Apr 16th, 2015 at 11:29 AM. Reason: changed "not" to note in first sentence

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Excel VBA... Quick Add Note Macro

    In the Worksheet_SelectionChange event I have this:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Column = 3 Then
            Call Module1.addNote(Target.Row)
        End If
    End Sub
    In Module1 I have this:

    Code:
    Public noteCurr As String
    Public noteNew As String
    
    Sub addNote(myRow As Long)
        Dim ws As Worksheet
        
        Set ws = ActiveSheet
        noteCurr = ws.Range("d" & myRow).Value
        ufNote.Show
        If Len(noteNew) > Len(noteCurr) Then
            ws.Range("d" & myRow).Value = noteNew
        End If
    End Sub
    In my user form (ufNote) I have this:

    Code:
    Private Sub btnAdd_Click()
        Module1.noteNew = Module1.noteCurr & vbCrLf _
            & Format(Now(), "yyyy-MM-dd") & vbCrLf & TextBox1.Text
        TextBox1.Text = ""
        Me.Hide
    End Sub
    
    Private Sub btnCancel_Click()
        Textbox1.Text=""
        Me.Hide
    End Sub
    My notes are in column D.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Posts
    74

    Re: Excel VBA... Quick Add Note Macro

    vbfbryce, thank you, I'll put this together in a few and get back to you to let you know if I was successful. Again, you're amazing and I'm learning a lot from you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width