|
-
Nov 4th, 2008, 08:50 AM
#1
Thread Starter
PowerPoster
vba - excel
I want match a pair of value with algebric summ( +-=0... for example 1,00 and -1,00 is matching) and if the summ is=0 insert zero in column Z...
Naturally after the code finish the summ of cells with the index Zero in Z must be =0...
But the code rerturn other total of summ, please help
Last edited by luca90; Jan 11th, 2009 at 06:35 AM.
-
Nov 4th, 2008, 10:16 AM
#2
Re: vba - excel
Why do you want this to do with a code when you can do it with a formula?
What I understand from the above is that if Cell A2 = 1 and Cell I2 = -1 then Cell Z2 should be zero... If my understanding is correct then insert this formula in Cell Z2
=IF(AND(ABS(A2)=ABS(I2),A2+I2=0),0,"")
and then you can drag the formula down...
Hope I have understood your query correctly?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2008, 10:26 AM
#3
Thread Starter
PowerPoster
Re: vba - excel
 Originally Posted by koolsid
Why do you want this to do with a code when you can do it with a formula?
What I understand from the above is that if Cell A2 = 1 and Cell I2 = -1 then Cell Z2 should be zero... If my understanding is correct then insert this formula in Cell Z2
=IF(AND(ABS(A2)=ABS(I2),A2+I2=0),0,"")
and then you can drag the formula down...
Hope I have understood your query correctly?
hI koolsid, tks for reply but no you not understand is my english not good! sure.
My ryally prob:
I want to loop all cells in column I with this:
loop first cell i column I with other il list and if the algebric summ between one in list is =0 then insert in Z the value ZERO for this pair, go the next cell and loop between other cells in list the algebric summ is =0 then insert ZERO in column Z for this pair, ecc...
To test if the summ of mached cells are = the code work fine...
Just have maked a code in wbook, but not work.
Tks pizza for you, sure
-
Nov 4th, 2008, 10:54 AM
#4
Re: vba - excel
I like pepperonni 
loop first cell i column I with other il list
What is this other list?
Can you give specific examples like I have done above?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2008, 10:56 AM
#5
Thread Starter
PowerPoster
Re: vba - excel
 Originally Posted by koolsid
I like pepperonni
What is this other list?
Can you give specific examples like I have done above?
sorry, other values in columnm I
-
Nov 4th, 2008, 11:16 AM
#6
Re: vba - excel
So you mean the If I take the value in Cell I2 and compare it with other values in Column I and if it satisfy's the condition mentioned above then put a zero in respective cell in Column Z for example
I2= -1 and I3=1 so Z3 should be zero? And similarly Z15 should be Zero?
Is my understanding correct?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2008, 11:25 AM
#7
Thread Starter
PowerPoster
Re: vba - excel
 Originally Posted by koolsid
So you mean the If I take the value in Cell I2 and compare it with other values in Column I and if it satisfy's the condition mentioned above then put a zero in respective cell in Column Z for example
I2= -1 and I3=1 so Z3 should be zero? And similarly Z15 should be Zero?
Is my understanding correct?
yes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1 PIZZA AND SPAGHETTI.
-
Nov 4th, 2008, 11:26 AM
#8
Re: vba - excel
Not sure if this is how you want it... Try it and tell me...
vb Code:
Sub Test()
Dim lrow As Long, rng As Range, cell As Range
lrow = 223
Set rng = Range("I2:I" & lrow).SpecialCells(xlCellTypeVisible)
For Each cell In rng
If Abs(Range("I2").Value) = Abs(cell.Value) _
And (Range("I2").Value + cell.Value) = 0 Then
'Set value of Cell in Col Z = 0
Range("Z" & cell.Row).Value = 0
End If
Next cell
End Sub
Last edited by Siddharth Rout; Nov 4th, 2008 at 11:38 AM.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|