Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I previously posted my problem in another section but I didn't fin any answer to solve my problem as I want... here is my previous post : My problem is that I have a sheet with thousands of lines like those ( used "_" to align my column because space are not working) : CLIENTS PRODUCT QTY TOTAL Roger __ product1 __ 2 __ 080$ Roger __ product1 __ 3 __ 120$ Lynda __ product1 __ 1 __ 040$ Lynda __ product2 __ 1 __ 050$ Lynda __ product3 __ 1 __ 040$ Lynda __ product3 __ 2 __ 080$ and I need to add quantity and total for each time the client and th product is the same to obtain something like this : CLIENTS PRODUCT QTY TOTAL Roger __ product1 __ 5 __ 200$ Lynda __ product1 __ 1 __ 040$ Lynda __ product2 __ 1 __ 050$ Lynda __ product3 __ 3 __ 120$ Now I think that making a macro in VBA could be the best thing to d that...but I'm not good in VBA...I know C and PHP but not reall VBA...anyway here is my code (it doesn't work) so if someone can tel me what's wrong and how to fix it please! (Sorry I didn't find a way to make multiple spaces to align my cod correctly). Dim i As Integer Dim qty As Integer Dim total As Integer qty = 0 total = 0 For i = 1 To 100 If Cells(A, i) = Cells(A, i + 1) Then If Cells(B, i) = Cells(B, i + 1) Then 'Updates the quantity qty = Cells(C, i) + Cells(C, i + 1) Cells(C, i) = qty 'Updates total total = Cells(D, i) + Cells(D, i + 1) Cells(D, i) = total 'On delete row i+1 Rows("i+1:i+1").Select Selection.Delete Shift:=c1Up End If Else End If Next -- Pwe ----------------------------------------------------------------------- Pwel's Profile: http://www.excelforum.com/member.php...fo&userid=2619 View this thread: http://www.excelforum.com/showthread.php?threadid=39513 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
Create a newworksheet with VBA code and put VBA code in the new worksheet module | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |