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

:)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,812
Messages
5,833,803
Members
430,233
Latest member
cbutts

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top