Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 25th, 2003, 02:41 PM
Authorized User
Join Date: Aug 2003
Location: , PA, USA.
Posts: 24
Thanks: 0
Thanked 1 Time in 1 Post
Default Selecting a column

I have a excel sheet with 5 columns (A,B,C,D,E). I want to wite a macro to select column D and E and then change its font color. I have merged cells in Column A. What happens is that due to merged cells when i write the statement
         columns ("D:E").select or Range("$D:$E").select
it selects the whole sheet(from column A to column E). Could someone suggest a wayout to select column D and E only with merged cells in Column A.


Ajitpal S Padda
Ajitpal S Padda
Reply With Quote
  #2 (permalink)  
Old December 11th, 2003, 04:30 AM
Registered User
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Loop through all rows and check if the MergeCells property is set to True for the cell in column A. Here's an example (don't forget to set myStartRow and myEndRow):

For n = myStartRow to myEndRow
  If Cells(n,1).MergeCells = True Then 'Cell in column A is merged with another one
    Cells(n,1).Font.ColorIndex = 5 'Changes the font color to blue
  Else 'No merged cell
    Range(Cells(n,4),Cells(n,5)).Font.ColorIndex = 5 'Changes the font color to blue
  End If

Note: this is not as fast as selecting columns, but it works...
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting elements up until a certain one Frode XSLT 5 January 19th, 2006 01:22 PM
previous column & next column ct Excel VBA 4 August 19th, 2005 04:50 AM
template column and bound column hidayah ASP.NET 1.x and 2.0 Application Design 1 April 9th, 2005 03:50 PM
Selecting once where there are many onlyu2 MySQL 1 March 25th, 2004 06:22 AM
Compare two Items of data(in column A and column B ever Excel VBA 6 February 13th, 2004 02:19 PM

All times are GMT -4. The time now is 06:49 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.