Populate specific cells and address specific worksheets

Posted on 2012-09-20
Last Modified: 2012-09-20
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

Question by:dbfromnewjersey
    LVL 13

    Accepted Solution

    Inside your For statement

    That is

    For Each sht In ActiveWorkbook.Worksheets
    if <> "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

        ActiveCell.FormulaR1C1 = "Hello World"
        Selection.HorizontalAlignment = xlCenter

    Open in new window

    To set color

        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 13158600
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With

    Open in new window


    Author Comment

    Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
    INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
    Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now