Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
How do I put wrapper code around the below, so that I can select a
range of "many" cells and have the code execute on each cell in turn? For each cell in selected range (selection) . . . Sub Adjust_Formula() ActiveCell.Formula = "=" & ActiveCell.Value * 2 & "*(QTR/4)" End Sub The formula works fine on a single cell. Many thanks, Fred Holmes |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
Sub do_all()
dim MyRange as range dim c as range 'adjust myrange to suit set MyRange = worksheet.range("a1:b15") for each c in MyRange call Adjust_Formula next c End Sub that should do it! (somebody else will probably have a simpler way of doing it, but..........) :) susan On Jun 1, 1:11*pm, Fred Holmes wrote: How do I put wrapper code around the below, so that I can select a range of "many" cells and have the code execute on each cell in turn? For each cell in selected range (selection) . . . Sub Adjust_Formula() * * ActiveCell.Formula = "=" & ActiveCell.Value * 2 & "*(QTR/4)" End Sub The formula works fine on a single cell. Many thanks, Fred Holmes |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
dim cell as range
for each cell in selection.cells cell.Formula = "=" & Cell.Value * 2 & "*(QTR/4)" next "Fred Holmes" wrote in message ... How do I put wrapper code around the below, so that I can select a range of "many" cells and have the code execute on each cell in turn? For each cell in selected range (selection) . . . Sub Adjust_Formula() ActiveCell.Formula = "=" & ActiveCell.Value * 2 & "*(QTR/4)" End Sub The formula works fine on a single cell. Many thanks, Fred Holmes |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
select a group of cells and run the following...
Sub Adjust_Formula() dim rng as range for each rng in selection rng.Formula = "=" & rng.Value * 2 & "*(QTR/4)" next rng End Sub -- HTH... Jim Thomlinson "Fred Holmes" wrote: How do I put wrapper code around the below, so that I can select a range of "many" cells and have the code execute on each cell in turn? For each cell in selected range (selection) . . . Sub Adjust_Formula() ActiveCell.Formula = "=" & ActiveCell.Value * 2 & "*(QTR/4)" End Sub The formula works fine on a single cell. Many thanks, Fred Holmes |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
actually, on 2nd thought, you should probably change this:
call Adjust_Formula to this: c.Formula = "=" & c.Value * 2 & "*(QTR/4)" susan On Jun 1, 1:34*pm, Susan wrote: Sub do_all() dim MyRange as range dim c as range 'adjust myrange to suit set MyRange = worksheet.range("a1:b15") for each c in MyRange * * * call Adjust_Formula next c End Sub that should do it! (somebody else will probably have a simpler way of doing it, but..........) :) susan On Jun 1, 1:11*pm, Fred Holmes wrote: How do I put wrapper code around the below, so that I can select a range of "many" cells and have the code execute on each cell in turn? For each cell in selected range (selection) . . . Sub Adjust_Formula() * * ActiveCell.Formula = "=" & ActiveCell.Value * 2 & "*(QTR/4)" End Sub The formula works fine on a single cell. Many thanks, Fred Holmes- Hide quoted text - - Show quoted text - |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Operate on each cell in range.
Many thanks to all who posted suggestions. The three lines of code
below are exactly what I needed. Fred Holmes On Mon, 1 Jun 2009 18:38:56 +0100, "Patrick Molloy" wrote: dim cell as range for each cell in selection.cells . . . next |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to Operate the active Excel Window with VB6 | Excel Programming | |||
The formula to operate in shhet2 please. | Excel Worksheet Functions | |||
Function to operate on ink linked to cell | Excel Worksheet Functions | |||
tell excel to operate in hexadecimal ( base 16)? | Excel Worksheet Functions | |||
Can Excel operate as Database? | Excel Programming |