Unable to cut and paste all cells from Sheet1 to Sheet2

systemx

New Member
Joined
Mar 27, 2013
Messages
4
Hi everyone. I have 5 rows currently residing in Column A in Sheet 1 that I would like to cut & paste into Column A in Sheet 2.

I am using the following macro below:
Code:
Sub Button1_Click()
    Dim LastCell As Range
    Dim LastCellRowNumber As Long
    Dim Incremental As Integer
        
    Sheets("Sheet1").Activate
    For Each Cell In ActiveSheet.UsedRange.Cells
        Set LastCell = Sheets("Sheet2").Cells(Rows.count, "A").End(xlUp)
        LastCellRowNumber = LastCell.Row
        'MsgBox LastCellRowNumber
        Sheets("Sheet2").Activate
        If (Range("A" & LastCellRowNumber).Text <> Empty) Then
            Incremental = 1
        Else
            Incremental = 0
        End If
        
        Cell.Cut Sheets("Sheet2").Range("A" & LastCellRowNumber + Incremental)
    Next
End Sub

The rows residing in Column A (Sheet1) are in the order below:
specs:HDD=WD, GFX=Leadtek, Mouse=Logitech
specs:HDD=Seagate, GFX=Nvidia, Mouse=Hp
specs:HDD=WD, GFX=Leadtek, Mouse=Microsoft
specs:HDD=WD, GFX=Nvidia, Mouse=Dell
specs:HDD=Seagate, GFX=Asus, Mouse=Hp

Once I click the button in Sheet1, 4 rows get cut & pasted to Sheet2 and the following row below is left behind in Sheet1:
specs:HDD=Seagate, GFX=Nvidia, Mouse=Hp

I'm not sure why this is happening .. could someone please bring insight into why this is happening and how I can bring all 5 rows into Sheet2? Thank you for the help!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
try this. a copy of sheet 1 may be copied to sheet 3 to preserve original data.
experiment with small sample date first


Code:
Sub test()
Worksheets("sheet1").Cells.Cut
Worksheets("sheet2").Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
 
Upvote 0
try this. a copy of sheet 1 may be copied to sheet 3 to preserve original data.
experiment with small sample date first


Code:
Sub test()
Worksheets("sheet1").Cells.Cut
Worksheets("sheet2").Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

Hi venkat1926, your code suggestion works! I am rather curious however, the code I posted earlier .. was it unnecessary for me to go that route .. and is your code suggestion a better way of achieving a cut & paste from Sheet1 to Sheet2 effectively? I'm asking because I guess there are many ways to do it, and would like to know the best practice/method out there, thanks!
 
Upvote 0
personally Ithink best method is taht with which you are comfortable.
if you use copy paste you can use like this
range("a1').copy range("a5")

if youmuse cut paste my method may be suitable ;. I cannot say it is best method.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,794
Members
449,048
Latest member
greyangel23

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
Back
Top