Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Flexible procedure

This is a two part question:
Part 1: The question is a bit difficult to phrase clearly. If I have not
asked the question well, please tell me. I simplified this greatly and hope
I made no types in the simplification.

Part 2:
This is part of a procedure that will add a column to a data sheet. That
column will calculate its value based on two other columns. However, the
two other columns may change position from time to time. So far the
statements of interest a

Dim Temp_Column As Range
Dim data_sheet As Worksheet
Dim Status_Column_Number As Integer
Dim Mode_Column_Number As Integer

' The sheet containing the data will always be named "data"
Set data_sheet = Worksheets("data")

' The next line uses a function that will return a column as a range.
That column will be
' the column that is headed with "Status".
' The following line gets the number of the column.
Set Temp_Column = Select_Column_By_Name("Status", data_sheet)
Status_Column_Number = Temp_Column.Column

Set Temp_Column = Select_Column_By_Name("Mode", data_sheet)
Mode_Column_Number = Temp_Column.Column

At this point lest assume I have
Status_Column_Number = 2
Mode_Column_Number = 3

The next statement I want to do is this:

AA2.Formula = "=B2 - C2"

I want to set the formula in the cell of row 2 column AA to "B2 - C2"
The actual statement is more complicated but this will serve. How do build
the string "=B2 - C2" from the knowledge that I have the numbers 2 and 3
that represent columns B and C?

Thanks for your time,
Bryan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Flexible procedure

How about:

With data_sheet
.Range("aa2").Formula = "=" & .Cells(2, status_column_number).Address(0, 0) _
& "-" & .Cells(2, mode_column_number).Address(0, 0)
End With


Bryan wrote:

This is a two part question:
Part 1: The question is a bit difficult to phrase clearly. If I have not
asked the question well, please tell me. I simplified this greatly and hope
I made no types in the simplification.

Part 2:
This is part of a procedure that will add a column to a data sheet. That
column will calculate its value based on two other columns. However, the
two other columns may change position from time to time. So far the
statements of interest a

Dim Temp_Column As Range
Dim data_sheet As Worksheet
Dim Status_Column_Number As Integer
Dim Mode_Column_Number As Integer

' The sheet containing the data will always be named "data"
Set data_sheet = Worksheets("data")

' The next line uses a function that will return a column as a range.
That column will be
' the column that is headed with "Status".
' The following line gets the number of the column.
Set Temp_Column = Select_Column_By_Name("Status", data_sheet)
Status_Column_Number = Temp_Column.Column

Set Temp_Column = Select_Column_By_Name("Mode", data_sheet)
Mode_Column_Number = Temp_Column.Column

At this point lest assume I have
Status_Column_Number = 2
Mode_Column_Number = 3

The next statement I want to do is this:

AA2.Formula = "=B2 - C2"

I want to set the formula in the cell of row 2 column AA to "B2 - C2"
The actual statement is more complicated but this will serve. How do build
the string "=B2 - C2" from the knowledge that I have the numbers 2 and 3
that represent columns B and C?

Thanks for your time,
Bryan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Flexible procedure

Wow! That was fast. You know your Excel macros. I will start integrating
this tomorrow.
Thank you,
Bryan


"Dave Peterson" wrote in message
...
How about:

With data_sheet
.Range("aa2").Formula = "=" & .Cells(2, status_column_number).Address(0,
0) _
& "-" & .Cells(2,
mode_column_number).Address(0, 0)
End With


Bryan wrote:

This is a two part question:
Part 1: The question is a bit difficult to phrase clearly. If I have
not
asked the question well, please tell me. I simplified this greatly and
hope
I made no types in the simplification.

Part 2:
This is part of a procedure that will add a column to a data sheet. That
column will calculate its value based on two other columns. However, the
two other columns may change position from time to time. So far the
statements of interest a

Dim Temp_Column As Range
Dim data_sheet As Worksheet
Dim Status_Column_Number As Integer
Dim Mode_Column_Number As Integer

' The sheet containing the data will always be named "data"
Set data_sheet = Worksheets("data")

' The next line uses a function that will return a column as a
range.
That column will be
' the column that is headed with "Status".
' The following line gets the number of the column.
Set Temp_Column = Select_Column_By_Name("Status", data_sheet)
Status_Column_Number = Temp_Column.Column

Set Temp_Column = Select_Column_By_Name("Mode", data_sheet)
Mode_Column_Number = Temp_Column.Column

At this point lest assume I have
Status_Column_Number = 2
Mode_Column_Number = 3

The next statement I want to do is this:

AA2.Formula = "=B2 - C2"

I want to set the formula in the cell of row 2 column AA to "B2 - C2"
The actual statement is more complicated but this will serve. How do
build
the string "=B2 - C2" from the knowledge that I have the numbers 2 and 3
that represent columns B and C?

Thanks for your time,
Bryan


--

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
flexible find stan Excel Discussion (Misc queries) 3 August 22nd 09 04:19 PM
I NEED A FLEXIBLE FORMULA QC Coug Excel Worksheet Functions 7 April 14th 06 12:36 AM
Flexible Charts Phil Charts and Charting in Excel 2 January 27th 05 02:37 PM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM


All times are GMT +1. The time now is 05:29 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"