I've been trying to loop through a certain sheet number, I have 20 sheets that start all with M, like M1, M2 and so on till M20, my problem is that I'm looping and writing, but instead of writing only on the M sheets, I'm writing in all sheets.
Sub CountWSNames()
Dim I As Long
Dim xCount As Integer
For I = 1 To ActiveWorkbook.Sheets.Count
If Mid(Sheets(I).Name, 1, 1) = "M" Then xCount = xCount + 1
ThisWorkbook.Worksheets(I).Range("A50") = "V" 'This line must write only to M sheets
Next
MsgBox "There are " & CStr(xCount) & " sheets that start with 'M'", vbOKOnly, "KuTools for Excel"
End Sub
Small piece of code similar to mine.
ThisWorkbook.Worksheets(I).Range("A50") = "V"
This line must only affect the Cell ("A50") on sheets starting with M.