Hi everyone,
I'm rather new to VBA, but I have managed to set up two userforms in two spreadsheets. The code for some of the functions is identical, for instance:
-checking whether a branch name already exists in the spreadsheet (BNCheckButton_Click())
-updating an existing record (UpdateExistingButton_Click())
-saving a new record and exiting the form (OKCloseButton_Click())
-saving a new record and starting a new record (OKNextButton_Click())
-clearing the form (ClearForm())
-saving the form (SaveForm())
-filling the form (FillForm())
The problem is, that the code works in one spreadsheet (FranchisingTest) but not the other (LeasingTest 2). I can't for the life of me work out what the difference is, and why it won't work in the second sheet.
Essentially, when I open FranchisingTest, I can do all of the base things I need to do: search for an existing record, update it, create a new one, etc. But when I try to do the same thing in LeasingTest 2, I keep getting 'Run-time error: '1004': Application-defined or object-defined error', and it's generally pointing at one of these lines:
C.Value = Intersect(LastFind.EntireRow, LastFind.Parent.Columns(C.Tag))
(in FillForm())
or
Intersect(LastFind.EntireRow, LastFind.Parent.Columns(C.Tag)) = C.Value
(in SaveForm())
I've attached both spreadsheets. Can anyone help me figure out what's going on? I'm tearing my hair out!!
Thanks so much!
FranchisingTest.xls
LeasingTest 2.xls
Bookmarks