Firstly, I am not a VBA whizz by any means, I know just a little bit and get by............
I have this code which I have copied from another spreadsheet, and pasted into sheet3 in "view code"
When I double click to activate the code, the first thing it does is open the spreadsheet that I copied the code from, but I just want it to run the code!
How does it know the location of the other spreadsheet? What am I missing?
TIA
I have this code which I have copied from another spreadsheet, and pasted into sheet3 in "view code"
Code:
Sub Auto_Open()
On Error Resume Next
Application.OnDoubleClick = "updateFromLeft"
End Sub
Sub updateFromLeft()
Dim WasProtected As Boolean
On Error GoTo myhandler
If ActiveCell.Row = 4 And ActiveCell.Column > 9 And ActiveCell.Column < 40 Then
Dim response As VbMsgBoxResult
response = MsgBox("Are you sure you want to copy yesterday's data over?", vbYesNo)
If response = vbNo Then Exit Sub
If ThisWorkbook.ActiveSheet.ProtectContents = True Then
ThisWorkbook.ActiveSheet.Unprotect Password:="grange"
WasProtected = True
Else
WasProtected = False
End If
ActiveCell.Offset(, -1).EntireColumn.Copy Destination:=ActiveCell.EntireColumn
If WasProtected Then ThisWorkbook.ActiveSheet.Protect Password:="grange"
Exit Sub
Else
Application.SendKeys "{F2}"
Exit Sub
End If
myhandler:
If Application.ScreenUpdating <> True Then Application.ScreenUpdating = True
Application.SendKeys "{F2}"
End Sub
When I double click to activate the code, the first thing it does is open the spreadsheet that I copied the code from, but I just want it to run the code!
How does it know the location of the other spreadsheet? What am I missing?
TIA