Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB.net select column and format
Hi,
I am using VB.net 2005 with Excel 2003. I need to select a single column and apply formating to it. Can someone please explain how to do this? Thanks, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB.net select column and format
What sort of formatting do you mean? The basic code would be something
like Dim RangeToFormat As Excel.Range Dim WS As Excel.Worksheet RangeToFormat = DirectCast( _ XLApp.Workbooks("Book1.xls"). _ Worksheets.Item("Sheet1"), Excel.Worksheet). _ Range("A1").EntireColumn WS = RangeToFormat.Worksheet RangeToFormat = _ XLApp.Intersect(WS.UsedRange, RangeToFormat) RangeToFormat.Font.Bold = True This sets the variable RangeToFormat to that portion of column F that resides within the used range of the worksheet "Sheet1" in workbook "Book1.xls". Once it has that range object, it applies a Bold format to the text font. If your module uses Option Strict On (and you should be doing that), you need the DirectCast on the worksheet. If you have Option Strict Off in effect, you don't need the DirectCast. If this code does not suffice, please post back with much more detail about what you are trying to do, the code you have now that doesn't work, and an explanation of what you want to accomplish. Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Fri, 29 Jan 2010 09:05:01 -0800, irishrose wrote: Hi, I am using VB.net 2005 with Excel 2003. I need to select a single column and apply formating to it. Can someone please explain how to do this? Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA: Column Select then Data Select then return to cell A1 | Excel Discussion (Misc queries) | |||
how to select a single column when this column cross a merged cell | Excel Programming | |||
Shortcut to select column with data in previous column | Excel Discussion (Misc queries) | |||
select detail in column B if column A = date | Excel Worksheet Functions | |||
When I select "format cells", the format dialog box does not disp. | Excel Worksheet Functions |