[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

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

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
wally_davis
Asked:
wally_davis
1 Solution
 
zorvek (Kevin Jones)ConsultantCommented:
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
 
wally_davisAuthor Commented:
Perfect solution Kevin! Thank you very much.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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