Forum Discussion

Guano458's avatar
Guano458
Copper Contributor
Apr 20, 2023

Expanding notes column

I have a spreadsheet that has a notes column.  But, occasionally that column is not big enough to hold the size of the note to be entered. I want to be abled to double_Click the notes column and have space open that allows the user to enter bigger notes, and I want that expanded area to be tied to the row in which the double click event happened.  I have tried to get  a solution from Chat GP4, but that didn't work out.  I am on Excel 365.  I just need to know if such a solution is possible, and a brief description of how it would work.

 

Thanks.

4 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Guano458 

    Yes, it is possible to create a solution for expanding the notes column in Excel 365. One approach is to use a VBA macro to create a userform that displays the notes for the selected row in a larger textbox. Here is a brief description of how it could work:

     

        Open the VBA Editor by pressing ALT+F11.

        Create a new userform by clicking Insert > UserForm.

        Add a textbox to the userform and set its properties to be multiline and scrollable.

        Add a command button to the userform and label it "Save".

        Add the following code to the userform module:

     

     

    Private Sub UserForm_Initialize()
        ' Get the active row and notes column
        Dim row As Integer
        row = ActiveCell.Row
        Dim notesCol As Integer
        notesCol = 5 ' Change this to the column number for your notes column
        
        ' Set the textbox value to the notes for the active row
        Me.TextBox1.Value = Cells(row, notesCol).Value
    End Sub
    
    Private Sub SaveButton_Click()
        ' Get the active row and notes column
        Dim row As Integer
        row = ActiveCell.Row
        Dim notesCol As Integer
        notesCol = 5 ' Change this to the column number for your notes column
        
        ' Save the textbox value to the notes for the active row
        Cells(row, notesCol).Value = Me.TextBox1.Value
        
        ' Close the userform
        Unload Me
    End Sub

     

     

    Add the following code to a new module:

     

     

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        ' Check if the double-clicked cell is in the notes column
        Dim notesCol As Integer
        notesCol = 5 ' Change this to the column number for your notes column
        If Target.Column = notesCol Then
            ' Show the notes userform
            NotesForm.Show
            Cancel = True
        End If
    End Sub

     

     

     

    This code sets up a listener for the BeforeDoubleClick event in the worksheet, and checks if the double-clicked cell is in the notes column. If it is, the code shows the notes userform and cancels the double-click event. The userform then displays the notes for the selected row in a larger textbox, and the user can edit them as needed. When the user clicks the "Save" button on the userform, the edited notes are saved back to the worksheet and the userform is closed.

     

    Note that you will need to adjust the column number for your notes column in the code, as well as any other userform properties or functionality as desired.

     

    Proposed solution with the support of AI. Haven't tried it myself, feedback would be nice :).

      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor

        Guano458 

        Yes, there is a limit to the number of characters that can be put into a userform textbox.

        The maximum number of characters that can be entered in a textbox is determined by the MaxLength property of the textbox control.

        By default, the MaxLength property is set to 0, which means there is no limit to the number of characters that can be entered.

        However, if you want to limit the number of characters that can be entered, you can set the MaxLength property to a specific value.

        For example, if you want to limit the textbox to 100 characters, you can set the MaxLength property to 100.

        Note that the maximum number of characters that can be entered in a textbox may also be limited by the available memory on your computer.

        If you try to enter a very large amount of text, you may run into performance issues or other problems.

         

        *Just copy/paste the basics from your answer 🙂

    • Guano458's avatar
      Guano458
      Copper Contributor
      I tried a solution like that using Chat GP4, but it wanted to store the notes in the registry for some unknown reason. I now have it working by having the notes saved in a separate worksheet when the notes cell is doublclicked in the CallLog sheet. It works, but is definitely not elegant. Your code seems tighter. Is there a limit to the number of characters that can be put into the userform text box? What AI are you using. I am using Chat GT4. I've learned one thing, you have to keep your questions simple. It tends to over complicate answers if you are a bit off on your question.

      Il give your code a try and report back.

      Thanks

Resources