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 November 13th, 2004, 07:12 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default find name and define range for Column

I want to define a range base on a header column, however, the column might not be in the same location (e.g. column A this time and column D next time).

I want to define the column range based on the header name regardless of location.

Any help would be greatly appreciated.

Here is my temporary work around to find and format the column, but this will not help me once I try to add the mathematical portion to my sheet.

I have two date columns that I format in this manner to make sure that they are accurately formatted.

currently the Range is defined as the entire column containing the active cell.

Code:
    Cells.Find(What:="PIDLDT", After:=ActiveCell, LookIn:=xlFormulas _
      , LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    Range(ActiveCell, ActiveCell.EntireColumn).Select
    Selection.TextToColumns Destination:=Range(ActiveCell, ActiveCell.EntireColumn), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 5), TrailingMinusNumbers:=True
    Selection.NumberFormat = "mm/dd/yy;@"


 
Old November 15th, 2004, 04:04 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The general method is :-
Code:
'Partial code
Set foundcell = Cells.Find(What:="PIDLDT")
foundcell.EntireColumn.Select
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
 
Old November 15th, 2004, 06:51 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, but that still does not give set that column to a range.

Is there something that will maybe give the column reference and
allow the range to be specified at that time?

Maybe I am trying to make this harder than it really is.



Qball
Silicon Hills
- New to VB
 
Old November 17th, 2004, 03:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

qball, what exactly do you want to achieve?

Do you want to find top/bottom of a range?
Do you want to format the content in the range?
Do you want to define a range?
 
Old November 17th, 2004, 03:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Define a range like this:

Dim rng as range
'select some range as done above
Set rng = selection

Now you can select the rng like this:

rng.Select





Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Column Range Nocturnl Excel VBA 3 December 29th, 2007 11:36 AM
find days per month in a date range rojer MySQL 1 June 5th, 2007 07:36 PM
how to find text within range of two tags dipsut XSLT 3 May 25th, 2007 04:27 PM
Using a variable to define a column name oxbrains Access 1 May 30th, 2006 06:34 AM
Need help to define dynamic range sunny76 Excel VBA 2 June 28th, 2005 11:01 PM





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