I’m currently doing this Sheets("Sheet2").Range("A1").Value = 35, but I want to a way to do just this Range("A1").Value = 35, by switching the sheet on a separate line before. I tried Sheets("Sheet2").Select, but that only switches the sheet it displays at the end to sheet 2.
I’m currently doing this Sheets(Sheet2).Range(A1).Value = 35 , but I want to a way
Share
You can use the
Withkeyword in VBA to achieve this. You can turn:Sheets("Sheet2").Range("A1").Value = 35into:
Note the leading . before Range. This means: use the object from the
WithstatementAlternatively, you could assign the worksheet to a variable and just use that.