I have this code which should work fine
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Auswertung")
...
ws.Range(Cells(2, 2), Cells(lastRow, lastCol)).NumberFormat = "0"
It however fails if the sheet is not selected. Error 1004, Methode Range fails for the object.
If I change it to
ws.Select
ws.Range(Cells(2, 2), Cells(lastRow, lastCol)).NumberFormat = "0"
it works.
why? In VBA I want to avoid select
.