• 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.

Help in Userform Error

Hi,

Iam unable to add data in user form below mentioned error in one particular code marked in red pls help on same.

>>> use code - tags <<<
Code:
Option Explicit

Private Sub CommandButton1_Click()

Sheet2.Activate
'  red line below
Range("a1").End(xlDown).Offset(1, 0).Value = Range("a1").End(xlDown).Value + 1 

Range("b1").End(xlDown).Offset(1, 0).Value = TextBox1.Value
Range("c1").End(xlDown).Offset(1, 0).Value = TextBox2.Value
Range("d1").End(xlDown).Offset(1, 0).Value = TextBox3.Value
Range("e1").End(xlDown).Offset(1, 0).Value = ComboBox1.Value

Unload Me

End Sub
 
That code works quite ok

Check that the VBA Sheet is Called Sheet2 as per the yellow below
The worksheet in Excel in my example is called Data
78014

Check that there is data from A1 down, as it won't look past gaps in the data
Also check that Column A isn't full of Spaces

Can you post your file?
 
Hi Sir,

thanks for your time i have completed by the below code thanks for your new idea..

Sir one request datepicker is not available in 365 is there is any way to add datepicker in userform
in addition controls "microsoft date and time picker control is not avaiable" option is not available hence..

>>> as already noted <<<
>>> use code - tags <<<
Code:
Option Explicit

Private Sub CommandButton1_Click()
Dim LR As Long

Sheet2.Activate
   
    LR = Cells(Rows.Count, 1).End(xlUp).Row + 1
   
    Cells(LR, 1).Value = TextBox1.Value
    Cells(LR, 2).Value = TextBox2.Value
    Cells(LR, 3).Value = TextBox3.Value
    Cells(LR, 4).Value = ComboBox1.Value
    Cells(LR, 5).Value = TextBox4.Value
   
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
    ComboBox1.Value = ""

Unload Me

End Sub
 
Last edited by a moderator:
Back
Top