MultiPage problem with multiple pages

Wicked_

Board Regular
Joined
Jun 5, 2018
Messages
81
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.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Have you checked the sheet the data is going to for any extraneous data?

Perhaps something on row 100 or thereabouts?
 
Upvote 0
Hi.

Yeah. Nothing at all at cell A100.
I've even tried copying one of the other sheets, changed the name of it, wiped it clean, and tried. does A1,A2,A3, A101. Then i saved, removed A3, and tried again, straight to A101. hmmm
 
Upvote 0
What happens if you use this,
Code:
iRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1

instead of this for to find the next empty row?
Code:
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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
Back
Top