Hello,
I was advised that the cells in a sheet cannot be the same as a Textbox in a Userform - However can the formatting be passed to a cell from the textbox in a Userform?
JOhn
Hello,
I was advised that the cells in a sheet cannot be the same as a Textbox in a Userform - However can the formatting be passed to a cell from the textbox in a Userform?
JOhn
What do you mean by formatting? Are you trying to choose the font or fill color...?
Ben Van Johnson
Cell Field color
Example of code in textbox in Userform
![]()
Private Sub txtacw_Change() Dim sValue As String Dim xValue As Double 'Get the value in the textbox as a string sValue = Me.txtacw.Value 'Color the TextBox BackGround Color if the value is numeric If IsNumeric(sValue) Then xValue = CDbl(sValue) If xValue >= 50# And xValue < 100# Then Me.txtacw.BackColor = RGB(255, 246, 143) 'Yellow ElseIf xValue >= 100# Then Me.txtacw.BackColor = RGB(240, 128, 128) 'Red Else Me.txtacw.BackColor = RGB(152, 251, 152) 'Green End If End If End Sub
Passing it back to my sheet:
Any Thoughts?![]()
Dim fullname As String, _ lACRow As Variant lACRow = Me.lstMyData.ListIndex With Sheets("EmployeeData") 'find the employee name in record base Set lACRow = .Range("A:A").Find(txtfullname.Text) If lACRow Is Nothing Then MsgBox "Name not found" Exit Sub End If .Range("A" & lACRow.Row).Resize(columnsize:=11).Value = Array( _ txtfullname.Text, _ txthiredate.Text, _ txtaht.Text, _ txtacw.Text, _ txtquality.Text, _ cbodepartments.Text, _ txtadherence.Text, _ txtvoc.Text, _ txtnps.Text, _ txtfcr.Text, _ cboteams.Text) End With End Sub
Use something like this:
![]()
Dim j As Long j = TextBox1.BackColor Range("A1").Interior.Color = j
ProtonLeah,
Is this placed in a current code I have above or is this an addition to the code?
I'm still guessing, but try:
![]()
Option Explicit Dim fullname As String, _ lACRow As Variant lACRow = Me.lstMyData.ListIndex With Sheets("EmployeeData") 'find the employee name in record base Set lACRow = .Range("A:A").Find(txtfullname.Text) If lACRow Is Nothing Then MsgBox "Name not found" Exit Sub End If .Range("A" & lACRow.Row).Resize(columnsize:=11).Value = Array( _ txtfullname.Text, _ txthiredate.Text, _ txtaht.Text, _ txtacw.Text, _ txtquality.Text, _ cbodepartments.Text, _ txtadherence.Text, _ txtvoc.Text, _ txtnps.Text, _ txtfcr.Text, _ cboteams.Text) '---------------------------------------- ' assuming you want the cell to have the same color as "txtquality", for example, then try: .Range("A" & lACRow.Row).Interior.Color = txtquality.BackColor '---------------------------------------- End With End Sub
ProtonLeah,
This diod not effect the color of the Quality Cell in the EmployeeData Sheet
John
Maybe a sample workbook with sensitive info deleted. This is what I think you are asking for: The form has tow textboxes and the button fills the active cell and the below right with the textbox backcolors.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks