Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Having two variable's in a macro

I have 500 rows of numbers each with an option button beside it. I
need Excel to recognize a certain cell when a certain option button is
selected. I'd like to do it with out entering in 500 different lines
of code. Below is my code. I need the R17C3 to be a variable and
change with which option button is selected. So the option button will
need to be a variable also. Any idea on how or if I can pull this
off?


Private Sub OptionButton1_Click()
Union(Sheets("READY MIX").Range("C13:C60"), Sheets("READY
MIX").Range("F13:F60"), Sheets("READY MIX").Range("I13:I60"),
Sheets("READY MIX").Range("L13:L60"), Sheets("READY
MIX").Range("O13:O60"), Sheets("READY MIX").Range("R13:R60"),
Sheets("READY MIX").Range("U13:U60"), Sheets("READY
MIX").Range("X13:X60")).FormulaR1C1 = _
"='READY MIX-MAIN'!RC+('READY MIX-MAIN'!RC*(1-(LF!
R23C3/100)))*(LF!R17C3)/100"
End Sub

Thanks,
Keith
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Having two variable's in a macro

Here is the best approach. The option button has a linked cell property
which will put either true or false in a cell. Make the linked cells in one
column. Then make a worksheet change that looks for changes in the column
where the true or false is located. You will only need one macro to handle
all the cases.

"Keith" wrote:

I have 500 rows of numbers each with an option button beside it. I
need Excel to recognize a certain cell when a certain option button is
selected. I'd like to do it with out entering in 500 different lines
of code. Below is my code. I need the R17C3 to be a variable and
change with which option button is selected. So the option button will
need to be a variable also. Any idea on how or if I can pull this
off?


Private Sub OptionButton1_Click()
Union(Sheets("READY MIX").Range("C13:C60"), Sheets("READY
MIX").Range("F13:F60"), Sheets("READY MIX").Range("I13:I60"),
Sheets("READY MIX").Range("L13:L60"), Sheets("READY
MIX").Range("O13:O60"), Sheets("READY MIX").Range("R13:R60"),
Sheets("READY MIX").Range("U13:U60"), Sheets("READY
MIX").Range("X13:X60")).FormulaR1C1 = _
"='READY MIX-MAIN'!RC+('READY MIX-MAIN'!RC*(1-(LF!
R23C3/100)))*(LF!R17C3)/100"
End Sub

Thanks,
Keith

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Having two variable's in a macro

Joel,

I think you're on to something. I'm working on setting up a test run
now.

Thanks,
Keith
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
How to calcuate 6 variable's contribution towards a fixed sum??? Alexander Excel Discussion (Misc queries) 2 April 20th 10 09:46 AM
How to populate Label1.Caption with a variable's value Dave O Excel Discussion (Misc queries) 3 April 25th 08 03:20 PM
Return the Row of a Variable's location xjetjockey Excel Discussion (Misc queries) 1 December 22nd 06 11:52 PM
getting a variable's name Philipp Excel Programming 1 October 25th 04 03:13 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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