inputting data from a userform in one format and matching a column name inserting in a 2nd page

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
I currently have a userform that works perfectly with the first sheet and dont want to change that. What I would like to do is add this information into a 2nd sheet that has a different layout. It would be something like this
Classwork
Drafts
Records
Portfolio
Final
98%78%23%98%0%
78%23%78%78%
78%89%0%78%
23%23%78%23%
23%98%98%

<tbody>
</tbody>

Each of these columns is named the same as the headers. In my form I would like for it to input as it is now in sheet1 (GradeBook) and for Sheet2 I would like for the grade only to be input into sheet2. Somehow it would need to match the correct column using the assignment name given using a combobox in the form. Here is the main part of the script for the info input.

Code:
Private Sub cmdSubmit_Click()
    Application.ScreenUpdating = False
    Dim NextRw As Long
    Dim ws As Worksheet
    Dim startRow As Long
    Dim CelFormat As String

    Set ws = Courses
    NextRw = ws.Cells(Rows.Count, 1).End(xlUp).Offset(2, 0).Row
    If NextRw < 6 Then NextRw = 6
    '<< Add data to worksheet >>
    ws.Cells(NextRw + 0, "A") = Me.txtAssignmentName.Value
    ws.Cells(NextRw + 1, "A") = Me.txtDate.Value
    ws.Cells(NextRw + 1, "A") = "Due: " & Me.txtDate.Value
    ws.Cells(NextRw + 2, "A") = Me.txtAssignmentType.Value
    If (Me.txtPointsReceived.Value & "X" = "X") Then
        ws.Cells(NextRw + 0, "D").Value = "-"
    Else
        If InStr(1, txtPointsReceived, "%") = 0 Then   'and if txtAssignmentName.value matches sheets2 column name insert grade in next open cell that column starting at @ row3
            CelFormat = "0.00"
        Else
            CelFormat = "0.00%"
        End If
        With ws.Cells(NextRw + 0, "D")
            .NumberFormat = CelFormat
            .Value = Me.txtPointsReceived.Value
        End With
    End If
    If InStr(1, txtPointsPossible, "%") = 0 Then
        CelFormat = """/"" 0.00"
    Else
        CelFormat = """/"" 0.00%"
    End If
    With ws.Cells(NextRw + 0, "E")
        .NumberFormat = CelFormat
        .Value = Me.txtPointsPossible.Value
    End With

    Unload Me
End Sub

Hopefully this isnt hard to do and I explained it without sounding like a babbling baboon :)
 
Last edited:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
I have now edited the combo box so it populates using the headers in row1 of sheet2 (WeightedPage) if that helps at all.

Code:
Sub UserForm_Initialize()
    Dim rheadings As Range
    Dim cl As Range
    Set rheadings = Sheets("WeightedPage").Range("A1:I1")
    For Each cl In rheadings
        Me.txtAssignmentType.Value = "Assignment"
        Me.txtAssignmentType.AddItem cl.Value
    Next cl
 '   txtAssignmentType.Value = "Assignment"
 '   txtAssignmentType.List = Array("Assignment", "Homework", "Test")
End Sub

I have done countless search variations and cannot seem to find this sort of scenario.

Well have a goodnight it is late for me, hopefully someone is bored and can lend a hand on this.
 
Upvote 0

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
I have gotten closer but still 2 bugs to work out
1st) get the code to start data input at row 3
2nd) get the data to be put in next available cell in the column

currently this code works but input the data in row2 after the headers and then if more data is added in the same column it over rights it here is what I have so far ********* are the separators for the code

also why bad code sometimes give the result of "Microsoft Excel" in the cell? I have search the code and see nothing that would input that. Just curious on this part.


Code:
Private Sub cmdSubmit_Click()
    Application.ScreenUpdating = False
    Dim NextRw As Long
    Dim ws As Worksheet
    Dim startRow As Long
    Dim CelFormat As String
    Dim rFind As Range

    Set ws = Courses
    NextRw = ws.Cells(Rows.Count, 1).End(xlUp).Offset(2, 0).Row
    If NextRw < 6 Then NextRw = 6
    '<< Add data to worksheet >>
    ws.Cells(NextRw + 0, "A") = Me.txtAssignmentName.Value
    ws.Cells(NextRw + 1, "A") = Me.txtDate.Value
    ws.Cells(NextRw + 1, "A") = "Due: " & Me.txtDate.Value
    ws.Cells(NextRw + 2, "A") = Me.txtAssignmentType.Value
    '*********************** Start New Code *****************************************
    With Sheets("WeightedPage").Columns("A:I")
        Set rFind = .Find(What:=Me.txtAssignmentType.Value, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Not rFind Is Nothing Then
            rFind.Offset(1, 0) = Me.txtPointsReceived.Value
        End If
    End With
    '************************ End New Code ******************************************
    If (Me.txtPointsReceived.Value & "X" = "X") Then
        ws.Cells(NextRw + 0, "D").Value = "-"
    Else
        If InStr(1, txtPointsReceived, "%") = 0 Then
            CelFormat = "0.00"
        Else
            CelFormat = "0.00%"
        End If
        With ws.Cells(NextRw + 0, "D")
            .NumberFormat = CelFormat
            .Value = Me.txtPointsReceived.Value
        End With
    End If
    If InStr(1, txtPointsPossible, "%") = 0 Then
        CelFormat = """/"" 0.00"
    Else
        CelFormat = """/"" 0.00%"
    End If
    With ws.Cells(NextRw + 0, "E")
        .NumberFormat = CelFormat
        .Value = Me.txtPointsPossible.Value
    End With

    Unload Me
End Sub
 
Upvote 0

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
If someone gets a second could you please let me know am I not giving enough information or not explaining it well enough? I know folks volunteer their time here so curious am I not as close as I think and this requires too much work for a freebie? I ask so I know if I should hire a freelancer to finish this up or be patient. Do not want anyone to think I do not appreciate all the help everyone gives I know I have learned a great deal in the past month and very grateful. Thank you in advance.
 
Upvote 0

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
okay going to take this one over to a freelance site. Would have been nice to have got a reply to my last question.
 
Upvote 0

Forum statistics

Threads
1,191,671
Messages
5,987,956
Members
440,121
Latest member
eravella

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
Top