whschimmel
Thread Starter
- Joined
- Jul 7, 2008
- Messages
- 168
Hello,
I've got this code to get rid of all leading apostrophes in the Excel (2003) Cels:
This code runs fine when I use the shortkey for it (CTRL + R), but when I try to autorun it I get an error:
When I click the debug button, this line is selected:
How can I autorun this code on opening of Excel, I would also like to run the code only if the sheetname is: "qryOfficeNetForeign"
I am no VBA expert, so am getting only errors
Thanks,
Wouter
I've got this code to get rid of all leading apostrophes in the Excel (2003) Cels:
Code:
Sub Auto_Open()
Dim S As Range, temp As String
Worksheets("qryOfficeNetForeign").Activate
With Worksheets(1)
If MsgBox("Are you sure you want to remove all leading apostrophes from the entire sheet?", _
vbOKCancel + vbQuestion, "Remove Apostrophes") = vbCancel Then Exit Sub
Application.ScreenUpdating = False
For Each S In ActiveSheet.UsedRange
If S.HasFormula = False Then
'Gets text and rewrites to same cell without the apostrophe.
S.Value = S.Text
End If
Next S
Application.ScreenUpdating = True
End Sub
Code:
Runtime Error 91: Object Variable Or With Block Variable Not Set
Code:
For Each S In ActiveSheet.UsedRange
How can I autorun this code on opening of Excel, I would also like to run the code only if the sheetname is: "qryOfficeNetForeign"
I am no VBA expert, so am getting only errors
Thanks,
Wouter