Changing some code

johnbird1988

Board Regular
Joined
Oct 6, 2009
Messages
199
Hello

I have the below colde that will look for the next blank row and insert it the vaule of my user form. I would like to use this the other way round and look for the next blabk column in column a and inseart the values in the user form.

Can some please help with changing the code. I have been trying and keep getting errors.

Thank you

John

Code:
Application.ScreenUpdating = False
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Matrix")
 
lRow = ws.Cells(Rows.count, 1) _
  .End(xlUp).Offset(1, 0).Row
  
If Trim(Me.TextBox4.Value) = "" Or Trim(Me.TextBox3.Value) = "" Or Trim(Me.TextBox1.Value) = "" Or Me.ComboBox1 = "" Or Me.ComboBox2 = "" Then
  Me.TextBox4.SetFocus
  MsgBox "Please complete all the fields (Employee End Date is Optional)"
  Exit Sub
End If
With ws
    .Cells(lRow, 1).Value = Me.TextBox4.Value
    .Cells(lRow, 2).Value = Me.TextBox3.Value
    .Cells(lRow, 3).Value = Me.ComboBox1.Value
    .Cells(lRow, 4).Value = Me.ComboBox2.Value
    .Cells(lRow, 5).Value = Me.TextBox1.Value
    .Cells(lRow, 6).Value = Me.TextBox2.Value
End With
Unload New_Employee
Application.ScreenUpdating = True
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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