HI I am new to this forum and new to VBA scripting s need some advice on a vba script I have written. It is giving me Compile Error: Variable not defined error message when I run it.
I am trying to work out a vba script for removing apostrophe sign from all the cells whether in middle or end or front of the text or a text cell with formula's . So I came with the below script which is giving me Comile error variable not defined.
Option explicit
Sub DeathToApostrophe()
'
Dim s As Range, temp As String
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 Cells In Sheets("Calc Sheet JDE").Select
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
Apart from this I have got another query that if I want this script to run on the whole workbook whether it has 10 or 20 sheets in it. In that case should I just put "This Workbook" instead of "Calc Sheet JDE").
Please advice if I am right or not, any other suggestions you are welcome to advice.
Another script I have written where I am getting the same compile error meassage with saying end with if and syntax error
Sub ApostroRemove()
For Each currentcell In Selection
If currentcell.HasFormula = False Then 'Verifies that procedure does not change the 'cell with the active formula so that it contains 'only the value. currentcell.Formula = currentcell.Value For Each currentcell In Selection If currentcell.HasFormula = False Then 'Verifies that procedure does not change the 'cell with the active formula so that it contains 'only the value. currentcell.Formula = currentcell.Value End If Next End Sub
If Next End Sub
End Sub
Thank you
CHeers
Amarjeet
Bookmarks