• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Have words bold shown on the excel file when typed in userform

kalua1231

Member
Hello guys i am trying to have typed words on the userform display on BOLD FONT when sent on the excel file.

Thanks for your time and help.

Code:
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("GENERAL")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 3).Value = Me.textbox_name.Value
ws.Cells(iRow, 4).Value = Me.textbox_name.Value
ws.Cells(iRow, 5).Value = Range("C2").Value
ws.Cells(iRow, 6).Value = "HOLD *"
ws.Cells(iRow, 7).Value = "1"
  ws.Cells(iRow + 1, 4).Value = Me.textbox_name.Value
    ws.Cells(iRow + 1, 5).Value = Range("C2").Value
    ws.Cells(iRow + 1, 6).Value = "HOLD *"
      ws.Cells(iRow + 1, 7).Value = "Z"

MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_name.Value = ""
Me.textbox_name.SetFocus



End Sub
 
Change you code as shown below

Code:
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("GENERAL")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 3).Value = Me.textbox_name.Value
ws.Cells(iRow, 3).Font.Bold = True

ws.Cells(iRow, 4).Value = Me.textbox_name.Value
ws.Cells(iRow, 4).Font.Bold = True

ws.Cells(iRow, 5).Value = Range("C2").Value

ws.Cells(iRow, 6).Value = "HOLD *"

ws.Cells(iRow, 7).Value = "1"
 
ws.Cells(iRow + 1, 4).Value = Me.textbox_name.Value
ws.Cells(iRow + 1, 4).Font.Bold = True
   
ws.Cells(iRow + 1, 5).Value = Range("C2").Value
   
ws.Cells(iRow + 1, 6).Value = "HOLD *"
   
ws.Cells(iRow + 1, 7).Value = "Z"

MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_name.Value = ""
Me.textbox_name.SetFocus

End Sub
 
Back
Top