I am trying to fix code that:
1 - opens a workbook
2 - writes data to the workbook
3 - saves workbook
4 - closes workbook
I am able to open the workbook needed. However, I am having an issue when I get to the "With Sheets("Log Record")" statement. The code is not looking at the file that was opened, it is looking at the other file. It appears that the newly opened file is not the active file. I can't figure out what is causing this. Thanks in advance for any comments.
Sub UpdateMasterFile()
Dim NextRow As Long
Dim wsLog As Worksheet
Workbooks.Open Filename:= _
"F:\Projects\Metrics\New Process\Log User Login Times History.xls"
With Sheets("Log Record")
NextRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & NextRow) = Date
.Range("B" & NextRow) = Time
.Range("E" & NextRow) = Environ("USERNAME")
.Range("F" & NextRow) = Environ("COMPUTERNAME")
End With
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
Bookmarks