Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Transfering Data From Userform To Sheet Under Relevant Column And Row

  1. #11
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    13
    Ok I will try again

    Paul

  2. #12
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    13
    I filled in the tag property,changed the sheets names but still get error

    What have I missed.Combobox2 entry decides on which sheet to enter data....is this the wrong approached?

    Thanks

    Paul
    Attached Files Attached Files

  3. #13
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Use this code

    Code:
    Option Explicit
    
    Private Sub UserForm_Initialize()
    
    
        Dim i As Long
        Dim vList As Variant
        Dim vSht As Variant
        
        For i = CLng(Date - 2) To CLng(Date + 7)
            vList = vList & Format(i, "dd/mm/yyyy") & ","
        Next i
        vList = Left(vList, Len(vList) - 1)
        ComboBox1.List = Split(Mid(vList, 1), ",")
        
        vList = ("C1,C2,C3,C4,C5")
        ComboBox2.List = Split(Mid(vList, 1), ",")
        
        vList = vbNullString
        vList = "-,"
        For i = CLng(Date - 2) To CLng(Date + 7)
            vList = vList & Format(i, "dd/mm/yyyy") & ","
        Next
        vList = Left(vList, Len(vList) - 1)
        ComboBox3.List = Split(Mid(vList, 1), ",")
        
        vList = vbNullString
        vList = "-,"
        For i = CLng(Date - 2) To CLng(Date + 7)
            vList = vList & Format(i, "dd/mm/yyyy") & ","
        Next
        vList = Left(vList, Len(vList) - 1)
        ComboBox4.List = Split(Mid(vList, 1), ",")
        
        vList = ("AA,BB,CC,DD,EE")
        ComboBox5.List = Split(Mid(vList, 1), ",")
        For Each vSht In Array("C1", "C2", "C3", "C4", "C5")
            With Worksheets(vSht)
                .Unprotect Password:="1357"
                .Protect UserInterfaceOnly:=True, Password:="1357"
            End With
        Next
    
    
    End Sub
    
    
    Private Sub CommandButton1_Click()
       
        Dim lngCol As Long
        Dim ctl As Object
        For Each ctl In Me.Controls
            If ctl.Tag <> vbNullString Then
                If ctl.Value = vbNullString Then MsgBox ctl.Tag: ctl.SetFocus: Exit Sub
            End If
        Next
        With Sheets(ComboBox2.Value)
           With .Cells(.Rows.Count, 2).End(xlUp).Offset(1)
                .Resize(, 6) = Array(ComboBox1.Value, ComboBox3.Value, ComboBox4.Value, ComboBox5.Value, TextBox1.Text, TextBox2.Text)
            End With
        End With
        
        For Each ctl In Me.Controls
            If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
        Next
        
    End Sub
    By the way, please correct the sheet name from "C1 " to "C1"
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #14
    Junior Member
    Join Date
    Jul 2013
    Posts
    20
    Rep Power
    0
    Thanks Excel fox

  5. #15
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    13
    Ok I got it now.That works
    I modified another sheet and it now works as well
    Thanks for all those who helped
    Paul

Similar Threads

  1. Replies: 30
    Last Post: 07-19-2013, 07:52 AM
  2. Replies: 8
    Last Post: 07-01-2013, 03:52 PM
  3. Group Pivot Data Based On Row Values In One Column
    By mrmmickle1 in forum Excel Help
    Replies: 10
    Last Post: 10-09-2012, 11:46 PM
  4. Copy Row To A New Sheet If A Value Found In Adjacent Column
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 08-17-2012, 05:42 PM
  5. Finding Last Used Row or Column In Excel Sheet
    By Rasm in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 04-14-2011, 03:17 AM

Posting Permissions

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