Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
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 …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

636 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