button

fadymadhoun

New Member
Joined
Sep 15, 2016
Messages
2
hi everyone,
i am not an excel professional, but i can manage.
i want to make a button at the end of a row that if clicked the whole row will move to the next sheet and the row will be deleted from the first worksheet
is this a possible thing to do?
i appreciate your help.
thank you very much
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try something like this:-
Code:
Private Sub CommandButton1_Click()
Dim Rw As Long
Rw = CommandButton1.TopLeftCell.Row
With Range("A" & Rw).EntireRow
    .Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
    .Delete
End With
End Sub
 
Upvote 0
thank you MickG for your help,
it actually works but not exactly like i want.
suppose you have 5 rows.
and the row number 4 is t he one you wanna move to the next spread sheet!
i think we shall have this button such like i choose the row and click on it then this specific row will move to the first available row in the next sheet, and the row below will move upwards.
is this alot of work?
thank you again!
 
Upvote 0
This will do it, it search column P if there is some thing in it then it will copy and paste that row/s in to the sheet called Dormant and delete from the source sheet. You can change column P to anything column you want, In this column have a dropdown list from which you can select Remove.

So if colum P have Remove in it it would copy and paste yjay row/rows to sheet Dormant and delete from source sheet

Code:
Private Sub CommandButton1_Click()

Dim LR As Long, NR As Long, a As Long
Application.ScreenUpdating = False
LR = Cells(Rows.Count, "P").End(xlUp).Row ' look in this column before copying
NR = Worksheets("Dormant").Range("P" & Rows.Count).End(xlUp).Offset(1).Row

For a = LR To 10 Step -1 ' does not copy anything above row 10 change if needed

  If UCase(Range("P" & a)) <> "" And Range("P" & a) <> "" Then '
  'this will copy and paste in to new sheet, change your range and sheet name here
  Range("A" & a & ":CG" & a).Copy
Worksheets("Dormant").Range("A" & NR).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
    NR = Worksheets("Dormant").Range("P" & Rows.Count).End(xlUp).Offset(1).Row
    Worksheets("Dormant").Range("A" & NR & ":CG" & NR).Value = Range("A" & a & ":CG" & a).Value
    
    'this will delete from source sheet remove if you don't want i to delet from source sheet
    Range("P" & a).EntireRow.Delete
  End If
Next a
Application.ScreenUpdating = True

End Sub
 
Upvote 0
Try this:-
Code:
Private Sub CommandButton2_Click()
Dim Ans As String
Ans = MsgBox("Is Row """ & Selection.Row & """ Correct", vbYesNo + vbInformation)
If Ans = vbYes Then
With Range("A" & Selection.Row).EntireRow
    .Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
    .Delete
End With
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,574
Members
449,173
Latest member
Kon123

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