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
292 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
ID: 34974832
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
ID: 34981053
Perfect solution Kevin! Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

910 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