Results 1 to 8 of 8

Thread: vba - excel

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    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.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: vba - excel

    Quote 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

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: vba - excel

    Tks pizza for you, sure
    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

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: vba - excel

    Quote 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

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: vba - excel

    Quote 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.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: vba - excel

    Not sure if this is how you want it... Try it and tell me...

    vb Code:
    1. Sub Test()
    2.     Dim lrow As Long, rng As Range, cell As Range
    3.    
    4.     lrow = 223
    5.    
    6.     Set rng = Range("I2:I" & lrow).SpecialCells(xlCellTypeVisible)
    7.    
    8.     For Each cell In rng
    9.         If Abs(Range("I2").Value) = Abs(cell.Value) _
    10.         And (Range("I2").Value + cell.Value) = 0 Then
    11.             'Set value of Cell in Col Z = 0
    12.             Range("Z" & cell.Row).Value = 0
    13.         End If
    14.     Next cell
    15. 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
  •  



Click Here to Expand Forum to Full Width