I want to make a macro that just inserts values in cells where the name of the worksheets is different from "Potable C1", "Potable C2", "Potable C3.1", "Potable C3.2", the code is not working because it is writing in all spreadsheets, can someone help me?
VBA Code:
Dim sh As Worksheet
Dim counter As Integer, ws As Integer
Public Sub WriteValues()
ws = ActiveWorkbook.Sheets.Count
For counter = 1 To ws
Worksheets(counter).Select
Set sh = ActiveSheet
If sh.Name <> "Potável C1" Or sh.Name <> "Potável C2" Or sh.Name <> "Potável C3.1" Or sh.Name <> "Potável C3.2" Then
Range("AC12").Select
If ActiveCell.Value = "" Then
With ActiveSheet.Range("AC12:AE12")
.Font.Bold = True
.Value = Array("Date", "Time", "Value")
.HorizontalAlignment = xlRight
End With
Else
End If
Range("AC13").Select
If ActiveCell.Value = "" Then
ActiveCell.Value = Range("U13").Value
Range("AE13").Value = WorksheetFunction.Sum(Range("W13:W108"))
Range("AF13").Value = "kWh"
Else
End If
Else
End If
Next counter
End Sub