R
ricowyder
Dear users,
I have the following macro, which is working fine (surely, there can
be improvement):
Private Sub CommandButtonUpdate_Click()
Dim i As Integer
Dim j As Integer
Dim idString As String
Dim sFilePath As String
Dim NameStaff As String
Dim wbNew As Workbook
Dim wb As Workbook
Set wb = ActiveWorkbook
Application.ScreenUpdating = False
For i = 1 To 32
j = i + 7
idString = ActiveSheet.Range("C" & j).Text
If idString <> "" Then
sFilePath = "L:\Year Planner\PresenceCheck\users\" & idString
Application.DisplayAlerts = False
Workbooks.Open sFilePath
Set wbNew = ActiveWorkbook
wb.Sheets(1).Range("D" & j).Value =
wbNew.Sheets(1).Range("D9").Value
wb.Sheets(1).Range("E" & j).Value =
wbNew.Sheets(1).Range("D20").Value
wbNew.Close
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
My problem: the purpose of this macro is to go into each staffs own
Excel file (all saved on server) to get the info
wb.Sheets(1).Range("D" & j).Value =
wbNew.Sheets(1).Range("D9").Value
wb.Sheets(1).Range("E" & j).Value =
wbNew.Sheets(1).Range("D20").Value
However, our staff has opened these files all the time. As soon as a
file is already opened, the update does not work anymore.
How can I avoid this problem (I guess it is read-only). PLEASE HELP!
Thanks a lot.
Regards,
Rico
I have the following macro, which is working fine (surely, there can
be improvement):
Private Sub CommandButtonUpdate_Click()
Dim i As Integer
Dim j As Integer
Dim idString As String
Dim sFilePath As String
Dim NameStaff As String
Dim wbNew As Workbook
Dim wb As Workbook
Set wb = ActiveWorkbook
Application.ScreenUpdating = False
For i = 1 To 32
j = i + 7
idString = ActiveSheet.Range("C" & j).Text
If idString <> "" Then
sFilePath = "L:\Year Planner\PresenceCheck\users\" & idString
Application.DisplayAlerts = False
Workbooks.Open sFilePath
Set wbNew = ActiveWorkbook
wb.Sheets(1).Range("D" & j).Value =
wbNew.Sheets(1).Range("D9").Value
wb.Sheets(1).Range("E" & j).Value =
wbNew.Sheets(1).Range("D20").Value
wbNew.Close
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
My problem: the purpose of this macro is to go into each staffs own
Excel file (all saved on server) to get the info
wb.Sheets(1).Range("D" & j).Value =
wbNew.Sheets(1).Range("D9").Value
wb.Sheets(1).Range("E" & j).Value =
wbNew.Sheets(1).Range("D20").Value
However, our staff has opened these files all the time. As soon as a
file is already opened, the update does not work anymore.
How can I avoid this problem (I guess it is read-only). PLEASE HELP!
Thanks a lot.
Regards,
Rico