Im tyring to write a VBA code to Copy the active row to a new sheet. Then Pull up a user form with a text box entry and list entry. When entered it will update the cells accordingly and update the date as well.
I am currently getting the Run-time error '91': Object varaible or with block variable not set. I can't Figure out where This error is coming from if you can help and explain it to me I would appreciate it greatly!
There are two files one to call the userform which is where i am getting the error.
Sub NewCange()
ChangeUserForm.Show
End Sub
and the userform code
Private Sub UserForm_Initialize()
Dim i As Integer, M As Integer, Result As Integer
Dim N As String
Dim MasterRange As Range, CopyRange As Range, NextRow As Range
Dim ActiveRow As Long
'Selects active row copies it and puts in empty row in the copy sheet
ActiveRow = ActiveCell.Row
With Worksheets("Master")
.Activate
.Cells(ActiveRow, 1).Select
.Cells(ActiveRow, 1).EntireRow.Copy
End With
With Worksheets("Records")
.Activate
.Cells(ActiveRow, 1).Select
Rows(ActiveRow).Select
End With
ActiveSheet.Paste
Destination:=Worksheets("Records").Cells(ActiveRow, 1)
'Below here is the inserting new change into excel sheet
Set MasterRange = Range(ActiveCell, ActiveCell)
Worksheets("Master").Activate
LocalListBox.Clear
'List of Locations for assets
With LocalListBox
.AddItem "TB01 "
.AddItem "TB02 "
.AddItem "TB03 "
.AddItem "TB04 "
.AddItem "TB05 "
.AddItem "TB06 "
.AddItem "TB07 "
.AddItem "TB07XP "
.AddItem "TB08 "
.AddItem "TB09 "
.AddItem "TB10 "
.AddItem "TB11 "
.AddItem "TB12 "
.AddItem "TB13 "
.AddItem "TB14 "
.AddItem "TB15 "
.AddItem "TB16 "
.AddItem "TB17 "
.AddItem "TB17XP "
.AddItem "TB18 "
.AddItem "TB19 "
.AddItem "TB20 "
.AddItem "TB21 "
.AddItem "TB23 "
.AddItem "TB24 "
.AddItem "TB25 "
.AddItem "TB26 "
.AddItem "TB27 "
.AddItem "TB27XP "
.AddItem "TB28 "
.AddItem "TB29 "
.AddItem "TB30 "
.AddItem "TB31 "
.AddItem "TB32 "
.AddItem "CAB3 "
.AddItem "CAB4 "
.AddItem "CAB5 "
.AddItem "CAB6 "
.AddItem "CAB7 "
.AddItem "CAB8 "
.AddItem "CAB9 "
.AddItem "CAB10 "
.AddItem "CAB12 "
.AddItem "CAB16 "
.AddItem "CAB17 "
.AddItem "CAB18 "
.AddItem "CAB19 "
End With
Set NameRange = ActiveCell
MasterRange = LocalListBox.Value
MasterRange.Offset(0, 2) = NameTextBox.Value
MasterRange.Offset(0, 1) = Date
Unload Me
End Sub