Macro to move data if someone says yes to amessagge box?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

Got a simple one that got me a bit.

I have two sheets

Sheet1 is called DATA1
Sheet2 is Data2

So all I want to do is have a macro that when I run it a message Box ask me "Do you want to copy data to Data2?"

If I answer Yes
Data1 D5 goes to Data2 d5 and Data1 H6 Goes to Data2 H6

If I say No Data2 d5 = "" Data2 H6 =""

if I click Cancel Nothing changes.

Please help if you can

Tony
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Code:
Select Case MsgBox("Do You Want To Copy", vbYesNoCancel)
    Case vbYes
        Sheets("Data2").Range("D5").Value = Sheets("Data2").Range("D5").Value
        Sheets("Data2").Range("H6").Value = Sheets("Data2").Range("H6").Value
    Case vbNo
        Sheets("Data2").Range("D5").Value = vbNullString
        Sheets("Data2").Range("H6").Value = vbNullString
    Case Else
End Select
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

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