Blanchetdb
Board Regular
- Joined
- Jul 31, 2018
- Messages
- 164
- Office Version
- 365
- Platform
- Windows
Hi,
I presently have coding that is fulfilling all my requirements except for the ability to save in a back up workbook. The back up workbook is located at (M:\HR\National Transfer Inventory\xxxx National Transfer Inventory Referral.XLSM)
this is my present code:
Can someone please provide some assistance with this
thanks
I presently have coding that is fulfilling all my requirements except for the ability to save in a back up workbook. The back up workbook is located at (M:\HR\National Transfer Inventory\xxxx National Transfer Inventory Referral.XLSM)
this is my present code:
Code:
Private Sub CmdAdd_Click()
Dim ws As Worksheet
Dim info, rw As Range, n As Long
Dim r As Range
Const strPwd As String = "Transfer19"
ThisWorkbook.Unprotect Password:=strPwd
Set ws = Worksheets("Inventory")
If Trim(Me.ListProv1.Value) = "" Then
Me.TxtFirst.SetFocus
MsgBox "Please select a Province"
Exit Sub
End If
If Trim(Me.ListCity1.Value) = "" Then
Me.TxtFirst.SetFocus
MsgBox "Please select a City"
Exit Sub
End If
With ws
.Unprotect Password:="Transfer19"
lr = .Range("C" & Rows.Count).End(xlUp).Row
For i = lr To 1 Step -1
If .Cells(i, "C") = CDbl(Me.TxtPRI.Value) Then .Rows(i).Delete
Next i
'get all the tombstone info into an array
info = Array(Me.TxtFirst.Value, Me.TxtLast.Value, _
Me.TxtPRI.Value, Me.TxtGR.Value, _
Me.TxtLV.Value, Me.TxtLinguistic.Value, _
Me.TxtEmail.Value, Me.TxtResumeNum.Value, _
Me.TxtReason.Value, Me.TxtDate.Value, Me.TxtTenure.Value)
'get the first empty row...
Set rw = .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).EntireRow
'loop over the province and city controls
For n = 1 To 10
'get province and city values
p = Me.Controls("ListProv" & n).Value
c = Me.Controls("ListCity" & n).Value
If n = 1 Or p <> "" Then
rw.Cells(1).Resize(1, 11).Value = info
rw.Cells(12).Value = p
rw.Cells(13).Value = c
Set rw = rw.Offset(1, 0)
End If
Next n
.Protect Password:="Transfer19"
End With
ThisWorkbook.Protect Password:=strPwd
ThisWorkbook.Save
End Sub
Can someone please provide some assistance with this
thanks
Last edited by a moderator: