CheekyDevil
New Member
- Joined
- Apr 15, 2018
- Messages
- 20
Hi experts,
I was trawling through countless pages of Google seeking an answer to this, with no success.
I have a VBA project throwing a "Runtime91" error advising a variable has not been declared, but doesn't tell me what variable. In Debug, it refers me to a single line of code that shows my userform on a command button press.
The only other indication I've had is the following codes "NumberFormat" but this should not be a variable, simply how the date and time is to be formatted when entered.
I've got OE at the top and still no joy.
Is there any code I can implement or any error checking options in VBA that will point me to the variable not declared?
Here's the code piece I'm referring to above:
I was trawling through countless pages of Google seeking an answer to this, with no success.
I have a VBA project throwing a "Runtime91" error advising a variable has not been declared, but doesn't tell me what variable. In Debug, it refers me to a single line of code that shows my userform on a command button press.
The only other indication I've had is the following codes "NumberFormat" but this should not be a variable, simply how the date and time is to be formatted when entered.
I've got OE at the top and still no joy.
Is there any code I can implement or any error checking options in VBA that will point me to the variable not declared?
Here's the code piece I'm referring to above:
Code:
Option Explicit
Dim ws As Worksheet
Dim LastRow As Long
Private Sub UserForm_Initialize()
Set ws = Sheet9
'Focus Log
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Adds Date
ws.Range("A" & LastRow).Value = Date
NumberFormat = "dd/mm/yyyy"
LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row + 1 'Adds Time
ws.Range("B" & LastRow).Value = Time
NumberFormat = "hh:mm:ss"
LastRow = ws.Range("C" & Rows.Count).End(xlUp).Row + 1 'Adds Username
ws.Range("C" & LastRow).Value = Environ("username")