SoraSenoie
New Member
- Joined
- Mar 24, 2021
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
I am unsurea bout why htis is not working and giving me a type missmatch error
VBA Code:
Private Sub SubmitCSR_Click()
Dim LastRow As Long
Dim ws As Worksheet: Set ws = Sheets("GP count")
'declare a variant array
Dim ReceivedV(1 To 6) As String
'populate the array
ReceivedV(1) = R1.Value
ReceivedV(2) = R2.Value
ReceivedV(3) = R3.Value
ReceivedV(4) = R4.Value
ReceivedV(5) = R5.Value
ReceivedV(6) = R6.Value
'declare a variant to hold the array element
Dim ReceivingN As Variant
'loop through the entire array
Dim strNames(1 To 6) As String
'populate the array
strNames(1) = ToggleButton1.Value
strNames(2) = ToggleButton2.Value
strNames(3) = ToggleButton3.Value
strNames(4) = ToggleButton4.Value
strNames(5) = ToggleButton5.Value
strNames(6) = ToggleButton6.Value
'declare a variant to hold the array element
Dim StockC As Variant
'loop through the entire array
For Each ReceivingN In Receivingv
For Each StockC In strNames
If StockC = True Then
LastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
ws.Range("C" & LastRow + 1).Value = StockC
LastRow = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row
ws.Range("E" & LastRow + 1).Value = ReceivingN
End If
Next StockC
Next ReceivingN
End Sub