Don't really know how to make a line of code red to highlight so sorry.
The line of code
has suddenly stopped working and I have no idea why, can anyone point out the more than likely glaringly obvious error I am missing please?
Dim FPath As String, folderpath As String
Dim HR1 As Worksheet
Private Sub CommandButton1_Click()
FPath = Sheets("Tyrant").Range("BA1").Value
Set HR1 = Workbooks.Open(FPath).Worksheets("HR")
folderpath = Sheets("Tyrant").Range("BA4").Value
HR.Birth.Text = Format(SetUp.PSD.Text, "d mm yyyy")
HR.NI.Text = Format(HR.NI.Text, "## ## ## ## #")
HR.Sort.Text = Format(HR.Sort.Text, "##-##-##")
HR.Salary.Text = Format(HR.Salary.Text, "Ģ0.00")
Application.ScreenUpdating = False
' FPath needs to be changed to the filepath for the main computer
' HR Database Path
With HR1.Range("C" & Rows.Count).End(xlUp).Offset(1)
.Value = HR.Initials.Value & "001"
.Offset(0, 1).Value = HR.Job.Text
.Offset(0, 2).Value = HR.Initials.Text
.Offset(0, 3).Value = HR.Birth.Text
.Offset(0, 4).Value = HR.Salutation.Text
.Offset(0, 5).Value = HR.Forename.Text
.Offset(0, 6).Value = HR.MiddleName.Text
.Offset(0, 7).Value = HR.Surname.Text
.Offset(0, 8).Value = HR.House.Text
.Offset(0, 9).Value = HR.Street.Text
.Offset(0, 10).Value = HR.Town.Text
.Offset(0, 11).Value = HR.County.Text
.Offset(0, 12).Value = HR.PostCode.Text
.Offset(0, 13).Value = HR.Tel.Text
.Offset(0, 14).Value = HR.EmCon.Text
.Offset(0, 15).Value = HR.Rel.Text
.Offset(0, 16).Value = HR.EmConTel.Text
.Offset(0, 17).Value = HR.NI.Text
.Offset(0, 18).Value = HR.Tax.Text
.Offset(0, 19).Value = HR.Bank.Text
.Offset(0, 20).Value = HR.Sort.Text
.Offset(0, 21).Value = HR.ACC.Text
.Offset(0, 22).Value = HR.Salary.Text
End With
HR.Hide
FPath.Save
FPath.Close
' This sets up a new folder at the below location for the new employee
If Len(Dir(folderpath & "\" & HR.Forename.Value & " " & HR.Surname.Value, vbDirectory)) = 0 Then
MKDir folderpath & "\" & HR.Forename.Value & " " & HR.Surname.Value
Else
MsgBox "This filepath already exists"
End If
FileCopy folderpath & "\Tyrant.xlsm", folderpath & "\" & HR.Forename.Value & " " & HR.Surname.Value & "\Tyrant.xlsm"
Application.ScreenUpdating = True
With folderpath & "\" & HR.Forename.Value & " " & HR.Surname.Value & "\Tyrant.xlsm" & Sheets("Tyrant").Range("A1").Value = HR.Initials.Text
End With
End Sub
Bookmarks