Hi.
I got a MultiPage with several pages, and a userform to input data on the next line on spesific sheets, but i got a issue.
I've had 4 pages for a long time, no issues what so ever, but then i added more pages, and copied the same code as i used for the 4 others, and just modified the names in the code to match the old ones, which worked perfectly.
But now i suddently i got a problem with 1 of the 4 original ones..
What its supposed to do, is when the excel program starts, i click submit, and then the userform fills in date, and some other values into the sheet, which looks for the next "available" line, and insert it. (like A1,A2,A3 etc)
But now suddently it goes from example A3, straight to A101. It skips everything between. Everytime it goes to 101, like its scripted to, but its not.
Here is the main code when i click the submit button the userform1:
ThisWorkbook.Worksheets("Maskin 39").Unprotect ("")
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Maskin 39")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.Textbox_Dato_39.Value) = "" Then
Me.Textbox_Dato_39.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.Textbox_Dato_39.Value
ws.Cells(iRow, 2).Value = Me.Textbox_Liter_39.Value
ws.Cells(iRow, 3).Value = Me.Textbox_Comments_39.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.Textbox_Dato_39.Value = ""
Me.Textbox_Liter_39.Value = ""
Me.Textbox_Comments_39.Value = ""
Me.Textbox_Dato_39.SetFocus
ThisWorkbook.Sheets("Maskin 39").Activate
ThisWorkbook.Worksheets("Maskin 39").Protect ("")
Anyone knows what could have gone wrong ? I havent modified the code itself, just copyied it to the other pages, and modified the names to math the new ones.
I got a MultiPage with several pages, and a userform to input data on the next line on spesific sheets, but i got a issue.
I've had 4 pages for a long time, no issues what so ever, but then i added more pages, and copied the same code as i used for the 4 others, and just modified the names in the code to match the old ones, which worked perfectly.
But now i suddently i got a problem with 1 of the 4 original ones..
What its supposed to do, is when the excel program starts, i click submit, and then the userform fills in date, and some other values into the sheet, which looks for the next "available" line, and insert it. (like A1,A2,A3 etc)
But now suddently it goes from example A3, straight to A101. It skips everything between. Everytime it goes to 101, like its scripted to, but its not.
Here is the main code when i click the submit button the userform1:
ThisWorkbook.Worksheets("Maskin 39").Unprotect ("")
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Maskin 39")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.Textbox_Dato_39.Value) = "" Then
Me.Textbox_Dato_39.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.Textbox_Dato_39.Value
ws.Cells(iRow, 2).Value = Me.Textbox_Liter_39.Value
ws.Cells(iRow, 3).Value = Me.Textbox_Comments_39.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.Textbox_Dato_39.Value = ""
Me.Textbox_Liter_39.Value = ""
Me.Textbox_Comments_39.Value = ""
Me.Textbox_Dato_39.SetFocus
ThisWorkbook.Sheets("Maskin 39").Activate
ThisWorkbook.Worksheets("Maskin 39").Protect ("")
Anyone knows what could have gone wrong ? I havent modified the code itself, just copyied it to the other pages, and modified the names to math the new ones.