I am having an issue where I am getting a "variable not defined" error but the variable has been defined (and defined correctly). VBA even autocorrects it when I input a lower case letter so it is definitely recognizing the variable but for some reason cannot compile when I run the macro. I had no issues with this document until recently but I have been adding code of the last few weeks. Anybody seen this issue before or have any suggestions to fix? The declaration and defining variables portion so my code is below. I get this same error for all the variables.
Private Sub btnTransferNonQ1ScrapTime_Click()
'declare variables
Dim scrapAmount, scrapTime As Long
Dim WhatHappened, whyHappened As String
Dim comments As Variant
Dim HlastRow, HlastRow1, HlastRow2, Klastrow As Long
Dim AlastRow As Date
Dim BlastRow, ClastRow, DlastRow, ElastRow As String
Dim Msg As String
Dim Response As String
Dim initials, Shift, workCenter, product, lineSpeed, finishedRollWidth As String
Dim Date1 As Date
Dim shiftTotalDowntime, shiftTotalScrap, shiftTotalQ1 As Long
'assign variables
Date1 = txtDate2.Caption
initials = txtInitials2.Caption
Shift = txtShift2.Caption
workCenter = txtWorkcenter2.Caption
product = txtProduct2.Caption
lineSpeed = txtLinespeed2.Caption
finishedRollWidth = txtFinishedrollwidth2.Caption
scrapAmount = txtScrapAmount.Value
scrapTime = txtScrapTime.Value
comments = txtComments.Value
Bookmarks