Excel 2010, VBA, Windows 7. intermediate VBA experience.
I have a large spreadsheet that generates other spreadsheets from downloaded data.
I am trying to optimize the coding so as not to keep repeating the same formatting code for multiple columns, for example.
Kindly responses to prior posts have shown how to do this with hard range references, but now I am stuck with logical references in a series.
I have tried to get the same formatting applied to the following series of ranges without success:
I have tried with no quotes, quotes around each range, and as above and it just won't compile. There may be ways to do it without a loop, but I am not that sophisticated in VBA yet.
Any help or suggestions would be much appreciated.
I have a large spreadsheet that generates other spreadsheets from downloaded data.
I am trying to optimize the coding so as not to keep repeating the same formatting code for multiple columns, for example.
Kindly responses to prior posts have shown how to do this with hard range references, but now I am stuck with logical references in a series.
I have tried to get the same formatting applied to the following series of ranges without success:
Code:
For Each myRange In Range("(Cells(6, 12), Cells(JRow, 12)), (Cells(6, 24), Cells(JRow, 24)), _
(Cells(6, 28), Cells(JRow, 28)), (Cells(6, 38), Cells(JRow, 38)), _
(Cells(6, 41), Cells(JRow, 41)), (Cells(6, 46), Cells(JRow, 46)), _
(Cells(6, 50), Cells(JRow, 50)), (Cells(6, 53), Cells(JRow, 53)), _
(Cells(6, 57), Cells(JRow, 57))") as Range
With myRange.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = -0.249946592608417
End With
Next myRange
I have tried with no quotes, quotes around each range, and as above and it just won't compile. There may be ways to do it without a loop, but I am not that sophisticated in VBA yet.
Any help or suggestions would be much appreciated.