copy data from one work book to another as a backup

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
161
Office Version
  1. 2016
Platform
  1. 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:
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:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Please take a minute to (re-)read the forum rules on cross-posting and then comply with them. Thanks. :)
 
Upvote 0
my apologies......I did source out help from OzGrid as well as I am in a time crunch to find a solution
 
Upvote 0
Add the actual link please.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top