0

I have some subs I use to format data in an Excel file. In particular, I have a sub that I can activate in the sheet("1.Parus") that has the line :

Range(Cells(2, 1), Cells(1000, 3)).Interior.Color = RGB(255, 255, 255)

But I have another sub to be activated in another sheet, where I want to be able to reste formatting in several sheets. And I get an error when trying this :

Worksheets("1.Parus").Range(Cells(2, 1), Cells(1000, 3)).Interior.Color = RGB(255, 255, 255)

Whereas code like : Worksheets("1.Parus").Columns("J:L").EntireColumn.Interior.Color = RGB(255, 255, 255) works fine.

I am a bit lost as to what does not work, and the available help I have found is not specific enough

1 Answer 1

0

It was a syntax issue : the Worsheets("W1"). only applies to the immediately following object. Therefore,

Worksheets("1.Parus").Range(Cells(2, 1), Cells(1000, 3)).Interior.Color = RGB(255, 255, 255) should be

Range(Worksheets("1.Parus").Cells(2, 1), Worksheets("1.Parus").Cells(1000, 3)).Interior.Color = RGB(255, 255, 255)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .