I have script that inputs data in two locations however I have ran into a hiccup. When I try and input my data it is putting it in columns A:E and not G:K
The first part of this script is working perfect however the part in the section "Data Input for active gradebook weighted key is not". Also is it possible to wrap a if around that part based on if G3 says percentage dont do this if G3 say weighted do this? It might be something I want to add later so figure I may as well try to get that part also.
Thank you
Private Sub cmdSubmit_Click()
Application.ScreenUpdating = False
Dim NextRw As Long, PointsReceived As Long, startRow As Long
Dim CelFormat As String, AssignmentType As String
Dim ws As Worksheet
Dim rFind As Range
Dim i As Integer
Set ws = ActiveSheet
NextRw = ws.Range("G190").End(xlUp).Offset(2, 0).Row
If NextRw = 7 Then NextRw = 6
'<< Add data to worksheet >>
ws.Cells(NextRw + 0, "G") = Me.txtAssignmentName.Value
ws.Cells(NextRw + 1, "G") = Me.txtDate.Value
ws.Cells(NextRw + 1, "G") = "Due: " & Me.txtDate.Value
ws.Cells(NextRw + 2, "G") = Me.txtAssignmentType.Value
' *********************************************************************
' Data input for active gradebook weighted key
' *********************************************************************
AssignmentType = txtAssignmentType.Value
If txtPointsReceived.Value = "" Then
PointsReceived = 1000
Else
PointsReceived = txtPointsReceived.Value
End If
i = 202
If AssignmentType = ActiveSheet.Range("G200").Value Then
For i = 202 To 1000
If ActiveSheet.Cells(i, 1).Value = "" Then
If PointsReceived <> 1000 Then
ActiveSheet.Cells(i, 1).Value = PointsReceived
End If
Exit For
End If
Next i
ElseIf AssignmentType = ActiveSheet.Range("H200").Value Then
For i = 202 To 1000
If ActiveSheet.Cells(i, 2).Value = "" Then
If PointsReceived <> 1000 Then
ActiveSheet.Cells(i, 2).Value = PointsReceived
End If
Exit For
End If
Next i
ElseIf AssignmentType = ActiveSheet.Range("I200").Value Then
For i = 202 To 1000
If ActiveSheet.Cells(i, 3).Value = "" Then
If PointsReceived <> 1000 Then
ActiveSheet.Cells(i, 3).Value = PointsReceived
End If
Exit For
End If
Next i
ElseIf AssignmentType = ActiveSheet.Range("J200").Value Then
For i = 202 To 1000
If ActiveSheet.Cells(i, 4).Value = "" Then
If PointsReceived <> 1000 Then
ActiveSheet.Cells(i, 4).Value = PointsReceived
End If
Exit For
End If
Next i
ElseIf AssignmentType = ActiveSheet.Range("K200").Value Then
For i = 202 To 1000
If ActiveSheet.Cells(i, 5).Value = "" Then
If PointsReceived <> 1000 Then
ActiveSheet.Cells(i, 5).Value = PointsReceived
End If
Exit For
End If
Next i
End If
' *********************************************************************
' Force formatting active gradebook received and possible
' *********************************************************************
If (Me.txtPointsReceived.Value & "X" = "X") Then
ws.Cells(NextRw + 0, "J").Value = "-"
Else
If InStr(1, txtPointsReceived, "%") = 0 Then
CelFormat = "0.00"
Else
CelFormat = "0.00%"
End If
With ws.Cells(NextRw + 0, "J")
.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, "K")
.NumberFormat = CelFormat
.Value = Me.txtPointsPossible.Value
End With
Unload Me
End Sub
Last second thought *** Can vba do formulas such as Sumif average and VLOOPUP on a veryhidden sheet?
Bookmarks