Bullet Points

longytravel

Board Regular
Joined
Aug 2, 2011
Messages
68
Guys,

i have the following code
this put a allows me to produce a bullet point when i start typing in the text box

I cant however get it to prodcue more than 'one bullet' i.e more than one line of text

Any way i can get more than one bullet into a text box?

i guess i would expect another bullet to appear when i hit return

Thanks as ever!

Code:
Private Sub TextBox1_Change()
Dim MyArray() As String
MyArray = Split(TextBox1.Text, vbCrLf)
For i = LBound(MyArray) To UBound(MyArray)
If Left(Trim(MyArray(i)), 1) <> "•" Then _
MyArray(i) = "• " & MyArray(i)
If i = 0 Then
TextBox1.Text = MyArray(i)
Else
TextBox1.Text = TextBox1.Text & vbCrLf & MyArray(i)
End If
Next i
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try moving your code to the TextBox1_KeyUp event and modifying it to read....

Code:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _
    ByVal Shift As Integer)
    Dim MyArray() As String
    Dim i As Long

    If KeyCode = 13 Then
        MyArray = Split(TextBox1.Text, vbCrLf)
        For i = LBound(MyArray) To UBound(MyArray)
            If Left(Trim(MyArray(i)), 1) <> "•" Then _
                MyArray(i) = "• " & MyArray(i)
                If i = 0 Then
                    TextBox1.Text = MyArray(i)
                Else
                TextBox1.Text = TextBox1.Text & vbCrLf & MyArray(i)
            End If
        Next i
    End If
End Sub

If you want the first line bullet to appear when you click or tab into the textbox
and be removed if the textbox is otherwise blank add....
Code:
Private Sub TextBox1_Enter()
    If Len(TextBox1.Text) = 0 Then
        TextBox1.Text = "• "
    End If
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If TextBox1.Text = "• " Then
        TextBox1.Text = ""
    End If
End Sub

To work as you describe, these TextBox1 properties should be set as folllows:
(set in the Properties window at design time or in UserForm1_Initialize)
Code:
TextBox1.EnterKeyBehavior = True
TextBox1.MultiLine = True
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top