Undo

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
Hello to All
With this code in sheet1 I select a cell , fill it in yellow, copy the entire row and past it in the first empty row in sheet2
Code:
Sub tranferdata()
With Selection.Interior
        .ColorIndex = 6
    With Selection.EntireRow.Copy
    Sheets("Sheet2").Select
    Range("A65536").End(xlUp).Offset(1, 0).Select
    ActiveSheet.Paste
    Sheets("Sheet1").Select
    End With
    End With
End Sub

What I need is if I choose to undo a "transfer" by doing this:
In sheet1 I click a "yellowed cell"
Cell turns to "no fill"
find matched cell in sheet2
When found does an EntireRow.delete .
Returns to sheet1

Thank you
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I beleive this will work for you:

Code:
Sub untransferdata()
If Selection.Interior.ColorIndex = 6 Then
 valuetofind = Selection.Value
 Incrementor = Sheets("Sheet2").Range("A65536").End(xlUp).Row + 1
 ValueFound = True
 Do
   Incrementor = Incrementor - 1
   If Incrementor = 0 Then
     MsgBox ("Error.  Value not found")
     ValueFound = False
     Exit Do
   End If
 Loop Until Sheets("Sheet2").Cells(Incrementor, 1).Value = valuetofind
 If ValueFound = True Then
   Sheets("Sheet2").Cells(Incrementor, 1).EntireRow.Delete
    Selection.Interior.ColorIndex = xlNone
 End If
End If
End Sub

Take care

Owen
 
Upvote 0
Owen great work with many thanks.
Hope you fly as well as you write code.
Best regards
Nick
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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