I'm reading the value from a spreadsheet and adding 1 on the read value using the below code. The error occurs at ModelNumber = PreviousModel + 1 and it says type mismatch. LastRowPrevious shows correct but PreviousModel shows empty. Please help. Thanks!
Option Explicit
Public ModelNumber As String
Public PreviousModel As String
Public FinalModelNumber As String
Sub TrackerInput()
Dim ModelDescription As String
Dim LastRowPrevious As String
LastRowPrevious = Worksheets("Model Tracker").Cells(Rows.Count, 1).End(xlUp).Row
If LastRowPrevious = 2 Then
ModelNumber = 2
PreviousModel = 1
Else
PreviousModel = Cells(LastRowPrevious, 1).Value
ModelNumber = PreviousModel + 1
End If
MsgBox ("You are creating a new model. Model number is " & ModelNumber)
End Sub

Worksheets("Model Tracker")isn't theActiveSheet, becauseRowsis referring to the active sheet but you're trying to get the last row on theModel Trackersheet. AndCells(LastRowPrevious, 1)also refers to the active sheet.Rows.Countis the number of rows in the active sheet. You want that to beWorksheets("Model Tracker").Rows.Count- gets really sloppy, really fast. hence most people would doWith Worksheets("Model Tracker")and doLastRowPrevious = .Cells(.Rows.Count, 1).End(xlUp).Rowinside thatWithblock (notice the dots).