Hi,
Need someones valued assistance. I have an workbook (AUTHPbWB) that has a sheet(Replacement) where data is input by end-user. it also has a button(Accept) which stores data in another worksheet based AUTHPbWB cell value D5. The variant data is in range B8-h15 of AUTHPbWM/replacement. When the accept button is clicked, it searches the database sheet for the next available row and inserts the new records. The database sheet has column A that has predefined values that should not change.
what im looking to do is, on clicking the accept button and when the records update in database, the corresponding values in column A of the database sheet get copied to another worksheet (data) only for the new records updated.
Spinning my head with this now. tried a few stunts, all failed
any help appreciated.
my current code is
Option Explicit
Dim wb As Workbook
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim wks As Worksheet
Dim wks1 As Worksheet
Dim wks2 As Worksheet
Sub Approved_Click()
Dim myPath As String
Dim strSubject As String
Dim strBody As String
Dim strTo As String
Dim strCC As String
Dim Filename As String
Dim strSheetName As String
Dim strBookName As String
Dim r As Long
Dim c As Range
Dim s As Range
Dim d As Range
Dim sFileName As String, sSheetName As String
Const sPath As String = "E:\Project 2013\Office Project 2013\Form Files\"
Set wks1 = ThisWorkbook.Worksheets("Replacement") 'ThisWorkbook.Worksheets("Replacement")
Set wks2 = ThisWorkbook.Worksheets("Data")
sFileName = wks1.Range("H5").Value
On Error Resume Next
Set wb1 = Workbooks.Open(sPath & sFileName)
On Error GoTo 0
If wb1 Is Nothing Then
Set wb1 = Workbooks.Add
wb1.SaveAs sPath & sFileName
ThisWorkbook.Worksheets("ReplTemp").Copy before:=wb1.Sheets(1)
wb1.Worksheets("ReplTemp").Name = "Replacement"
End If
Set wks = wb1.Worksheets("Replacement")
For Each c In wks1.Range("B8:B15").SpecialCells(xlCellTypeConstants)
r = wks.Range("B18").End(xlUp).Offset(1, 0).Row
If r > 15 Then
MsgBox ("Your have availed your monthly quota for application")
Exit Sub
End If
c.Resize(1, 6).Copy
wks.Range("B" & r).PasteSpecial (xlPasteValues)
wks1.Range("E24").Copy
wks.Range("H" & r).PasteSpecial (xlPasteValues)
Next c
Application.CutCopyMode = False
Application.ScreenUpdating = True
Bookmarks