Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
how to select a single column when this column cross a merged cell cnEagle Excel Programming 1 November 13th 07 04:49 AM
Shortcut to select column with data in previous column TJAC Excel Discussion (Misc queries) 1 July 10th 07 06:12 PM
select detail in column B if column A = date Dan B Excel Worksheet Functions 0 September 18th 06 04:46 PM
When I select "format cells", the format dialog box does not disp. Andy S. Excel Worksheet Functions 2 November 23rd 04 03:49 AM


All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"