Solved

Attempting to select a specific Excel sheet and work with Cell ranges to write and format the data

Posted on 2011-02-24
2
291 Views
Last Modified: 2012-05-11
I am attempting to select a specific Excel sheet within my Excel VBA Code. In selecting say "Sheet2" I am writing Excel headers and would also like, etc. like this
With oExcel.Sheets(1)
End With
The problem is that since the .Range and .Selection properties are on the same level as .Sheets property, I can't seem to work with Sheet2 like I need to as in the code below. I'm sure there's a way to get around this but I haven't figured it out yet.

Thank you for your help Experts!
Wallace
With oExcel
        .Range("A3", "A54").Select
        .Selection.Interior.ColorIndex = 1
        .Selection.Font.Name = "Tahoma"
        .Selection.Font.ColorIndex = 2
        .Selection.Font.Size = 10
        .Selection.Font.Italic = True
    End With

Open in new window

0
Comment
Question by:wally_davis
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
Comment Utility
With oExcel
   With .Sheets("Sheet1")
        With .Range("A3", "A54")
            .Interior.ColorIndex = 1
            .Font.Name = "Tahoma"
            .Font.ColorIndex = 2
            .Font.Size = 10
            .Font.Italic = True
       End With
    End With
End With

Kevin
0
 

Author Closing Comment

by:wally_davis
Comment Utility
Perfect solution Kevin! Thank you very much.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

744 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

18 Experts available now in Live!

Get 1:1 Help Now