Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]() HI OK thanks for your help with that - worked perfectly , first time. Much appreciated. I made a small variation , so that positive numbers , as well as negative , could be entered : ActiveCell.FormulaR1C1="=RC[1]+"&intNumber Thanks again. Best wishes. In article , Matt Richardson writes On 27 Jan, 11:16, Matt Richardson wrote: On 27 Jan, 05:16, Colin Hayes wrote: Hi I have a piece of code as part of a macro which subtracts 1 from a value in cell D2 ActiveCell.FormulaR1C1 = "=RC[1]-1" Sometimes , I need to vary this number. Rather than open the macro and change the code each time , is it possible to program a popup to request the value of the variable , and once executed proceed with the rest of the macro? Any help appreciated. This might work. Put it at the top of your code:- Dim intNumber as integer intNumber = inputbox("Please enter the number you wish to subtract by","Enter number") This will then store the number you wish to subtract by into the variable intNumber. The next bit of your code would then look like this:- ActiveCell.FormulaR1C1="=RC[1]-"&intNumber And that should pretty much do the trick. Hope this helps. Regards, Matt Richardsonhttp://teachr.blogspot.com You might want to change the 'Dim intnumber...' bit to this actually:- Dim intNumber as double The prior version will only work with integers and therefore would only work with whole numbers. Changing the type of variable means that you can subtract decimals as well. Regards, Matt Richardson http://teachr.blogspot.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro boxes: toggle on/off | Excel Discussion (Misc queries) | |||
Macro Boxes | Excel Discussion (Misc queries) | |||
Macro Boxes | Excel Discussion (Misc queries) | |||
Entering Variable Text in Text Boxes...... | Excel Discussion (Misc queries) | |||
Macro that can run combo boxes | Excel Discussion (Misc queries) |