I keep getting a run-time error of 91 which I searched up and it seems as if it's an issue of whether or not I set/declared my variables/objects properly. I'm pretty sure I referenced everything properly, and the same macro was working earlier... But then all of a sudden the vba macro broke. Any clues as to why this is the case?
Note: There are 2 separate workbooks. 1 workbook acts as a database for clients, and one workbook is a templated sheet where I can search for a client, and it autopopulates the templated sheet.
The error is found when assigning the variable LastRow with a value. I tried using Set in front, but it still didn't seem to work.
Sub AddNewClient()
Application.ScreenUpdating = False
Dim i As Long
Dim LastRow As Long
Dim strClient As String
Dim strEmail As String
Dim strPhone As String
Dim ClientDBWB As Excel.Workbook
Set CurrWkbk = ActiveWorkbook
ClientDBWB = Workbooks.Open("[SomePath][File Name.xlsx]")
***The Debugger shows the error here*** when assigning LastRow a value.
LastRow = ClientDBWB.Sheets("ClientDB").Cells(Rows.Count, "A").End(xlUp).Row + 1
strClient = CurrWkbk.Sheets("House").Range("C11:J11").Cells(1, 1).Value
strEmail = CurrWkbk.Sheets("House").Range("C12:J12").Cells(1, 1).Value
strPhone = CurrWkbk.Sheets("House").Range("C13:J13").Cells(1, 1).Value
With ClientDBWB.Sheets("ClientDB")
.Cells(LastRow, 1).Value = strClient
.Cells(LastRow, 2).Value = strPhone
.Cells(LastRow, 4).Value = strEmail
End With
MsgBox "Client is Added to the Database!"
Application.ScreenUpdating = True
If ClientDBWB Is Nothing
.