Hi all,
I need your assistance to help me to open, close & saved a database file.
Below is the VB Script ,
Thank you in advance 
Sub UpdateLogWorksheet()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range
'cells to copy from database sheet - some contain formulas
myCopy = "P1,E1,E2,E3,E4,E5,AI2,W3,W4,W5,W6,E6,P2,P3,P4,P5,AF5,AF6,AJ6"
Set inputWks = Worksheets("source")
Set historyWks = Workbooks("database.xlsx").Worksheets("data")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With
With inputWks
Set myRng = .Range(myCopy)
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please fill in all the YELLOW coloured cells!"
Exit Sub
End If
End With
With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "dd/mm/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
End Sub
Bookmarks