Code to merge cells

Roses8

Active Member
Joined
Aug 4, 2005
Messages
348
hi, Dont know how to start this please help!

IF column A = A/C number 5899 and 5898 and column C has an amount of -125 and -1300 then add the amounts together result in column C against 5899 and delete row 5898.

5898 -1300
5899 -125

result

5898 -1550

:)
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Roses8

Active Member
Joined
Aug 4, 2005
Messages
348
Hi, This what I have come up with the code below, but now im trying to say if cell = the codes below then code in to column 10 row 1 and so on but it debugs.


Sub TT()

Dim celltocopy As String



For i = 1 To Range("a65536").End(xlUp).Row
celltocopy = cells(i, 1).Value
If celltocopy = "AB089" And "AB090" Then
Range(cells(i, 1), cells(i, 4)).Select
Selection.Copy
cells(i, 10).Select
ActiveSheet.Paste
Else
End If
Next
i = i + 1
End Sub
 

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Try:

Code:
Sub TT()
Dim LastRow As Long, i As Long
Dim celltocopy As String

LastRow = Range("A65536").End(xlUp).Row

For i = 1 To LastRow
    celltocopy = Cells(i, 1).Value
    If celltocopy = "AB089" Or celltocopy = "AB090" Then
        Range(Cells(i, 1), Cells(i, 4)).Copy Destination:=Cells(i, 10)
    End If
Next i

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,540
Messages
5,572,794
Members
412,483
Latest member
deezina07
Top