Hello,
I have a below user form when I have some data in two columns:
First column is marked with viariables from Roll1val to Roll10val. Second colun accordingly: From Roll1 to Roll10. I'd like to write data in excell file row by row like with conditional check if in next row there are some data. If yes, write it in next row in excell sheet. If not, stop the macro. Can you help me as I don't know yet how to make variables in the loop ?
1st row: Roll1val , Roll1
2nd row: Roll2Val , Roll2
I have a below user form when I have some data in two columns:
First column is marked with viariables from Roll1val to Roll10val. Second colun accordingly: From Roll1 to Roll10. I'd like to write data in excell file row by row like with conditional check if in next row there are some data. If yes, write it in next row in excell sheet. If not, stop the macro. Can you help me as I don't know yet how to make variables in the loop ?
1st row: Roll1val , Roll1
2nd row: Roll2Val , Roll2
VBA Code:
Private Sub SubmitButton_Click()
Dim sh As Worksheet
Dim RollNo As String
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
RollNo = ExtraTest.Rolli
If Not RollNo Is Nothing Then
For i = 1 To 10
iRow = [Counta(Database!A:A)] + 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = ExtraTest.MFGNo.Value
.Cells(iRow, 3) = ExtraTest.FS
.Cells(iRow, 4) = ExtraTest.Fname
.Cells(iRow, 6) = "Dodatkowe testy"
.Cells(iRow, 7) = ExtraTest.Rollival
.Cells(iRow, 8) = [Text(Now(), "MM/DD/YYYY HH:MM")]
.Cells(iRow, 10) = "Otwarte"
.Cells(iRow, 19) = "Dodatkowe testy"
.Cells(iRow, 20) = ExtraTest.Testi
End With
Next i
End If
MsgBox ("Nowe zlecenie zostało zarejestrowane")
End Sub