Hi,
Can someone assit me by looking over my code below or alternativly at my workbook & make any suggestions as to why it won't execute when the file is shared?
This is my first attempt at VBA & I'm stumped!
It is part of a 'Scan in / Out' time capture workbook that I've written up.
Reason is that I need to share the work book & I can't seem to get the ___.RefreshAll to work.
My intention is to Refresh the current instance of the workbook just before information is written to a range so as to ensure it is written to an empty cell when multiple users are running the workbook.
The code is called from the 'Scan In / Out' button on my sheet. Link to workbook location is https://www.cubby.com/pl/Excel+help/_caf1f45734b54ccd8d3688322d6ef828
& the code in question is below.
I'm using 2010 but may need to run it on some older 2003 units.
Many thanks in advance.
Mat in Australia.
Can someone assit me by looking over my code below or alternativly at my workbook & make any suggestions as to why it won't execute when the file is shared?
This is my first attempt at VBA & I'm stumped!
It is part of a 'Scan in / Out' time capture workbook that I've written up.
Reason is that I need to share the work book & I can't seem to get the ___.RefreshAll to work.
My intention is to Refresh the current instance of the workbook just before information is written to a range so as to ensure it is written to an empty cell when multiple users are running the workbook.
The code is called from the 'Scan In / Out' button on my sheet. Link to workbook location is https://www.cubby.com/pl/Excel+help/_caf1f45734b54ccd8d3688322d6ef828
& the code in question is below.
I'm using 2010 but may need to run it on some older 2003 units.
Many thanks in advance.
Mat in Australia.
Code:
[Private Sub ScanInOut_Click()
Dim found As Boolean
Dim dtmNow As Date
Dim strName As String
Dim strCode As String
Dim Counter As Integer
Dim Check As Boolean
' Me.Hide
strCode = InputBox(Prompt:="Please Enter Your Pass Code.", _
Title:="ENTER YOUR CODE", Default:="Your Pass Code Here")
If strCode = "Your Pass Code Here" Or strCode = vbNullString Then
'MsgBox ("Error, default values were not updated in the 'Name' boxes")
CreateObject("Wscript.Shell").Popup "Error, Please try again", 2, "Auto-Close", 0
End If
'Exit Sub
'strCode = StrConv(strCode, vbLowerCase)
Counter = 0
Check = False
Do Until found = True
Counter = Counter + 1
If Sheets("Admin sheet").Range("R1").Offset(Counter, 3) = strCode Then
found = True
End If
If Sheets("Admin sheet").Range("R1").Offset(Counter, 3) = "" Then
CreateObject("Wscript.Shell").Popup "Name is not in list. Please see Admin.", 2, "Auto-Close", 0
'Unload Me
Exit Sub
End If
Loop
If Sheets("Admin Sheet").Range("R1").Offset(Counter, 3) = strCode Then
Counter = 0
found = False
Do Until found = True
If Sheets("Admin Sheet").Range("O13") = "Yes" Then
dtmNow = Sheets("Admin Sheet").Range("O15")
Else
dtmNow = Now
End If
If Sheets("Admin Sheet").Range("A1").Offset(Counter, 0) = strCode And Sheets("Admin Sheet").Range("A1").Offset(Counter, 6) = "" Then
Sheets("Admin Sheet").Range("A1").Offset(Counter, 6) = "@"
Sheets("Admin Sheet").Range("A1").Offset(Counter, 6) = dtmNow
found = True
CreateObject("Wscript.Shell").Popup "Punched out", 1, "Auto-Close", 0
'ActiveWorkbook.RefreshAll
'ActiveWorkbook.Save
'Unload Me
Else
If Sheets("Admin Sheet").Range("A1").Offset(Counter, 0) = "" Then
Sheets("Admin Sheet").Range("A1").Offset(Counter, 0).NumberFormat = "@"
Sheets("Admin Sheet").Range("A1").Offset(Counter, 0) = strCode
Sheets("Admin Sheet").Range("A1").Offset(Counter, 5) = dtmNow
found = True
CreateObject("Wscript.Shell").Popup "Punched in", 1, "Auto-Close", 0
'ActiveWorkbook.RefreshAll
'ActiveWorkbook.Save
End If
End If
Counter = Counter + 1
Loop
End If
ActiveWorkbook.Save
ActiveWorkbook.RefreshAll
'Call macro1
Call ScanInOut_Click
End Sub
/CODE]