Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macros and column selection

Hello, I am creating a macro and need it to automatically select certain
columns. the problem I am having is that every two weeks the number of
columns that need to be selected will increase by 1. I need it to select up
to the cell that has the words "Fiscal Date - All". Is this possible?

thanks, janet
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default macros and column selection

Janet,

Try some code like the following. This assumes that "Fiscal
Date - All" is in row 1.


Dim Rng As Range
Set Rng = Rows(1).Find("fiscal date - all")
If Not Rng Is Nothing Then
Range(Range("a1"), Rng).EntireColumn.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"JanetH" wrote in message
...
Hello, I am creating a macro and need it to automatically
select certain
columns. the problem I am having is that every two weeks the
number of
columns that need to be selected will increase by 1. I need it
to select up
to the cell that has the words "Fiscal Date - All". Is this
possible?

thanks, janet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macros and column selection

thanks so much Chip.

Sorry I should have explained myself better. I have the macro search for the
word Sick and then go down one row (to where the data is) and then I want it
to go across to the column just before the one that has the totals.

it looks like
Sick
05/06 01 05/06 02 .... Fiscal Date All
7.5 2.1 15.2

is that possible?

thanks, Janet

"Chip Pearson" wrote:

Janet,

Try some code like the following. This assumes that "Fiscal
Date - All" is in row 1.


Dim Rng As Range
Set Rng = Rows(1).Find("fiscal date - all")
If Not Rng Is Nothing Then
Range(Range("a1"), Rng).EntireColumn.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"JanetH" wrote in message
...
Hello, I am creating a macro and need it to automatically
select certain
columns. the problem I am having is that every two weeks the
number of
columns that need to be selected will increase by 1. I need it
to select up
to the cell that has the words "Fiscal Date - All". Is this
possible?

thanks, janet




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default macros and column selection

Watch your headers. You've spelled "fiscal data all" a couple of different
ways:

Option Explicit
Sub testme01()

Dim RngFiscal As Range
Dim RngSick As Range

With Worksheets("sheet1")
.Activate

With .Rows(1)
Set RngFiscal = .Find(what:="Fiscal Date All", _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
End With

If RngFiscal Is Nothing Then
MsgBox "Error in headers"
Exit Sub
End If

With .Range("a:a")
Set RngSick = .Find(what:="sick", _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
End With

If RngSick Is Nothing Then
MsgBox "Sick Not found"
Exit Sub
End If

'come down one row
Set RngSick = RngSick.Offset(1, 0)

.Range(RngSick, .Cells(RngSick.Row, RngFiscal.Column - 1)).Select

End With

End Sub

And this assumes that your data is in row 1 and column A--on Sheet1.

JanetH wrote:

thanks so much Chip.

Sorry I should have explained myself better. I have the macro search for the
word Sick and then go down one row (to where the data is) and then I want it
to go across to the column just before the one that has the totals.

it looks like
Sick
05/06 01 05/06 02 .... Fiscal Date All
7.5 2.1 15.2

is that possible?

thanks, Janet

"Chip Pearson" wrote:

Janet,

Try some code like the following. This assumes that "Fiscal
Date - All" is in row 1.


Dim Rng As Range
Set Rng = Rows(1).Find("fiscal date - all")
If Not Rng Is Nothing Then
Range(Range("a1"), Rng).EntireColumn.Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"JanetH" wrote in message
...
Hello, I am creating a macro and need it to automatically
select certain
columns. the problem I am having is that every two weeks the
number of
columns that need to be selected will increase by 1. I need it
to select up
to the cell that has the words "Fiscal Date - All". Is this
possible?

thanks, janet





--

Dave Peterson
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
Macros to protect worksheet and prevent locked cell selection Excel Enthusiastic[_2_] Excel Discussion (Misc queries) 1 April 23rd 07 09:44 AM
Row Selection or Column Selection or other ? wesbird Excel Programming 1 June 21st 05 08:11 PM
Add a column to a selection Pam Excel Programming 1 September 24th 04 02:56 PM
Last column in selection Lawlera Excel Programming 7 April 19th 04 12:40 PM
Macros - Range Selection Pam[_4_] Excel Programming 2 December 18th 03 03:04 AM


All times are GMT +1. The time now is 03:11 PM.

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

About Us

"It's about Microsoft Excel"