+ Reply to Thread
Results 1 to 4 of 4

Inserting values from a form to sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Inserting values from a form to sheet

    Hi,
    I have a form, from where I want to insert the values to a particular sheet. Can somebody please help me to help me out.
    The value from these textboxs needs to be inserted to sheet7 which I named as "Log"
    tbdate
    cbfilelist
    tbtoday
    tbtime

    On sheet7 I have inserted the headers as :
    Date
    File Name
    Today
    Time

    What I am doing is that, when I am pressing a button, it is asking me for a password.if the password matches then
    the values in the fields I mentioned is copied to the log sheet.
    I am using this code to do it but I am doing error. Please guide me.

    Private Sub cmdOverride_Click()
    
    Dim Pword As String
    Dim lrow As Long
    Pword = InputBox("Please input the password. ", "Change Date")
    
    If Pword = "" Then
           Exit Sub
    ElseIf Pword <> "z" Then
         MsgBox "Your password is wrong!", , "Sorry"
      
        Exit Sub
    Else
        
        lrow = Sheets("Sheet7").Range("A65536").End(xlUp).Row + 1
        With UserForm1
            .tbTime.Value = Format$(Now(), "hh:mm:ss AM/PM")
            .tbDate.Value = Format(Calendar1.Value)
            Range("A" & lrow).Value = .tbTime.Text
            Range("B" & lrow).Value = .tbDate.Text
        End With
     
    End If
    
    End Sub

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Inserting values from a form to sheet

    try this
    (change TextBox1 with yr textbox name...)
    Private Sub cmdOverride_Click()
    Dim Pword As String
    Dim lrow As Long
    Pword = InputBox("Please input the password. ", "Change Date")
    
    If Pword = "" Then
           Exit Sub
    ElseIf Pword <> "z" Then
         MsgBox "Your password is wrong!", , "Sorry"
      
        Exit Sub
    Else
    
     With Sheet7   'find next empty row using Column A
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
    Dim Wks As Worksheet
        
            .Cells(NextRw, 2).Value = Now
            .Cells(NextRw, 2).NumberFormat = "dd-mm- hh:mm"
    
            .Cells(NextRw, 3).Value = Me.TextBox1.Value
            .Cells(NextRw, 4).Value = Me.TextBox2.Value
            .Cells(NextRw, 5).Value = Me.TextBox3.Value
    End With
    End Sub
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    02-07-2011
    Location
    Bhutan
    MS-Off Ver
    Excel 2007
    Posts
    244

    Re: Inserting values from a form to sheet

    Thanks it worked !!!
    :D

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Inserting values from a form to sheet

    glad it helped you! :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1