title: Excel VBA Replacing Question Mark
body: <p>I have VBA code written up to find and replace question marks in all worksheets in a workbook. However it is not working, can anyone help me out to see where did i go wrong? </p>
  
  <pre><code>Sub ReplaceQM()
  
      Dim lRow As Long
      Dim lCol As Long
  
      totalSheet = ThisWorkbook.Sheets.Count
  
      MsgBox totalSheet
      For x = 1 To totalSheet
  
  
          lRow = ThisWorkbook.Sheets(x).Cells(Rows.Count, 1).End(xlUp).Row
          lCol = ThisWorkbook.Sheets(x).Cells(1, Columns.Count).End(xlToLeft).Column
  
  
          For Z = 1 To lRow
              For i = 1 To lCol
  
                  getPos = InStr(1, ThisWorkbook.Sheets(x).Cells(Z, i).Value, "~?")
  
                  If getPos &gt; 0 Then
  
                      ThisWorkbook.Sheets(x).Cells(Z, i).Value = Replace(ThisWorkbook.Sheets(x).Cells(Z, i).Value, "~?", " ")
  
                  End If
  
              Next i
          Next Z
      Next x
  End Sub   
  </code></pre>