Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
2003/2007
Range("A1").Value = Range("A1").Value * -1 will quickly flip "A1" 9999 to -9999 Let's assume that Set myRange = Range("A1:A3") How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. TIA EagleOne |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you have to resort to code use this:-
Sub marine() Set myrange = Range("A1:A3") For Each c In myrange c.Value = c.Value * -1 Next End Sub But if code can be avoided put -1 in a cell and copy. Select the range to filp and paste special|multiply. Mike " wrote: 2003/2007 Range("A1").Value = Range("A1").Value * -1 will quickly flip "A1" 9999 to -9999 Let's assume that Set myRange = Range("A1:A3") How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. TIA EagleOne |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike, I can not use the -1 in the CopyTo Cells PasteSpecial/Multiply option.
The For Next works fine. Thanks Any thoughts about initializng, multipling, pasting an array? Mike H <M wrote: If you have to resort to code use this:- Sub marine() Set myrange = Range("A1:A3") For Each c In myrange c.Value = c.Value * -1 Next End Sub But if code can be avoided put -1 in a cell and copy. Select the range to filp and paste special|multiply. Mike " wrote: 2003/2007 Range("A1").Value = Range("A1").Value * -1 will quickly flip "A1" 9999 to -9999 Let's assume that Set myRange = Range("A1:A3") How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. TIA EagleOne |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there
you could try something like the code below to iterate through each cell in the range Option Explicit Dim MyCell, MyRng As Range Private Sub CommandButton1_Click() Set MyRng = [A1:A3] For Each MyCell In MyRng MyCell.Value = MyCell.Value * -1 Next MyCell End Sub Hope this helps S |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look at PasteSpecial, values & multiply
Start by copying a cell that contains -1 Record a macro Regards, Peter T wrote in message ... 2003/2007 Range("A1").Value = Range("A1").Value * -1 will quickly flip "A1" 9999 to -9999 Let's assume that Set myRange = Range("A1:A3") How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. TIA EagleOne |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How does one "flip" the values in myRange?
As myRange.Value = myRange.Value * -1 does not work. Hi. To do it without a loop requires a slightly different technique: Sub Demo() [A1:A10] = [- A1:A10] End Sub -- HTH :) Dana DeLouis Windows XP & Excel 2007 wrote in message ... 2003/2007 Range("A1").Value = Range("A1").Value * -1 will quickly flip "A1" 9999 to -9999 Let's assume that Set myRange = Range("A1:A3") How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. TIA EagleOne |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dana,
is [A1:A10] = [- A1:A10] an Array usage in VBA? EagleOne "Dana DeLouis" wrote: How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. Hi. To do it without a loop requires a slightly different technique: Sub Demo() [A1:A10] = [- A1:A10] End Sub |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dana,
Can one get a variable into the [ ]? I attempted: [myRange] = [- myRange] then [myRange.address] = [- myRange.address] then x = myRange.address [x] = [- x] to no avail. "Dana DeLouis" wrote: How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. Hi. To do it without a loop requires a slightly different technique: Sub Demo() [A1:A10] = [- A1:A10] End Sub |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Sub test() [myrange] = [-myrange] End Sub worked fine for me in XL2003 and XL2007 -- Regards Roger Govier wrote in message ... Dana, Can one get a variable into the [ ]? I attempted: [myRange] = [- myRange] then [myRange.address] = [- myRange.address] then x = myRange.address [x] = [- x] to no avail. "Dana DeLouis" wrote: How does one "flip" the values in myRange? As myRange.Value = myRange.Value * -1 does not work. Hi. To do it without a loop requires a slightly different technique: Sub Demo() [A1:A10] = [- A1:A10] End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VLookup returning the sum of multiple values from one "code" | Excel Worksheet Functions | |||
Reverse a "row" of numbers (flip flop them)? | New Users to Excel | |||
Setting values for "TRUE","FALSE" and "#REF!" | Excel Programming | |||
Changing "returned" values from "0" to "blank" | Excel Worksheet Functions | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming |