• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Populate specific cells and address specific worksheets

I have a macro that I'd like to modify to format specific cells.  Just as a couple of examples,  how would I, say set Cell C4 to the string value "Hello World" and have it centered?  And how would I set, say cells B10 thru G10 to the RGB color value 200, 200, 200?

Finally, my macro currently runs a routine on every worksheet in my workbook.  However, I'd like to have it skip "Sheet1" as Sheet1 is of a totally different format and I don't want the macro run against is.  My macro currently reads:

For Each sht In ActiveWorkbook.Worksheets

How do I modify it to something like:

For Each sht In ActiveWorkbook.Worksheets EXCEPT SHEET1

Thanks
0
dbfromnewjersey
Asked:
dbfromnewjersey
1 Solution
 
Shanan212Commented:
Inside your For statement

That is

For Each sht In ActiveWorkbook.Worksheets
if sht.name <> "Sheet1" then
...
...
...
next sht

in the above way, it only go through your statements if the sheet name is not "Sheet1"


To set string in C4

    Range("C4").Select
    ActiveCell.FormulaR1C1 = "Hello World"
    Selection.HorizontalAlignment = xlCenter

Open in new window


To set color

 
  Range("B10:G10").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 13158600
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

Open in new window

0
 
dbfromnewjerseyAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now