UserForm textbox when Empty, change BackColor on Worksheet Column

jdgrapes

New Member
Joined
Nov 25, 2019
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi Guys, I in need of some expertise help, I have been working on and it is as well part of my learning curve. I have modified one of my old Userform database to create another one which has 5 textboxes, what I’ve been trying to do
That if textbox1 is > 1 and textbox5 =””. I would like to ‘Worksheet Cell, Backcolor =RGB(100 , 100, 100), which in my database ‘SampleTestFile’ happens to be is Column 6.
I have never attempted this before so my knowledge is very limited. With many thanks, I quite appreciated if I can get some help with some explanation
Thanks
VBA Code:
Private Sub cmdAdd_Click()
'dimention the variable
    Dim DataSH As Worksheet
    Dim Addme As Range
'set the variable
    Set DataSH = Sheet1
'error handler
    On Error GoTo errHandler:
'set variable for the destination
    Set Addme = DataSH.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
'hold in memory and stop screen flicker
    Application.ScreenUpdating = False
    If Me.textbox1 = "" Then
    MsgBox "Insufficient Data"
    Exit Sub
    End If
      
'send the values to the database
    With DataSH
   
'Textbox5 Format
    If Me.textbox2 > 1 & Me.textbox4 = "" Then
    DataSH.Cells(Rows.Count, 6).Me.textbox4.BackColor = RGB(100, 100, 100)
    End If
   
'add the unique reference ID then all other values
         
'Column B = Seq IS Auto Generated
    Addme.Offset(0, -1) = DataSH.Range("C6").Value + 1
   
'Column.C = Time.A
   Addme.Value = Me.textbox1
  
'Column.D = Time.B
    Addme.Offset(0, 1).Value = Me.textbox2
   
'Column.E = Time.B-A
    Addme.Offset(0, 2).Value = Me.textbox3
   
'Column.F = Time.in Minutes
    Addme.Offset(0, 3).Value = Me.textbox4
    
    End With
 
Last edited by a moderator:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,215,847
Messages
6,127,270
Members
449,372
Latest member
charlottedv

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