Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2005, 09:44 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default VBA Excel highlight all columns

I have this code:

Code:
Sub select_row_b()
Range("A1", Range("A1").End(xlDown)).Select
End Sub
I am looking for code that will take each column in turn (in a loop) and highlight it.

Picco

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old April 18th, 2005, 10:00 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

to select a whole column, use this code (column A as example)

Sheet1.Range("A:A").Select
 
Old April 18th, 2005, 10:10 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

This code below gives me the error:

Run_time Error: 1004
Application-defined or object-defined error

____________________________________________

Code:
Sub select_row_a()
Sheet1.Range("A:A").Select
End Sub
does this highlight all columns in turn?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
 
Old April 18th, 2005, 02:34 PM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

that is possible if you havent selected sheet1 first (and, if you have it on another sheet, you need do try ThisWorkbook.Sheets(shtname)

so this should help you

Code:
thisworkbook.sheets(shtname).select   'shtname is the name of your sheet
activesheet.range("A:A").select
 
Old April 19th, 2005, 02:15 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dim myloop As Integer
Range("A1").EntireColumn.Select
myloop = 1
Do Until myloop = 256
ActiveCell.Offset(0, 1).EntireColumn.Select
myloop = myloop + 1
Loop

cheers

Matthew






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using VBA to Sort Multiple Columns meclive Excel VBA 1 July 30th, 2008 11:04 AM
vba question on adding certain columns csilla Excel VBA 0 July 30th, 2008 05:25 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Trouble hiding and unhiding columns in VBA jtmelb Excel VBA 0 February 14th, 2007 07:04 PM
How to highlight in Excel haiying Excel VBA 5 April 6th, 2005 01:29 PM





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