Display the box to confirm and deliver message before running the code
When the code are added to ribbon, there may be the instance that we click on the code by mistake.
Because we can't undo, we may lose the original data.
In addition, there are certain criteria to apply for each code (For example, where is data range located
or where is the result located).
To avoid that, I want to set an alert before the code run by adding some more lines in the code, which :
- Display the message box .
For example : "Row 1 is header.
Data in column A,B,C.
Result in column E,F,G"
- Display the confirm box to run the code : "Do you want to run the code?"
What is the line of code I need to insert ?
Keys to the Problem Display the box to confirm and deliver message before running the code
(make a copy before you run this code)
Data in Active Sheet in columns A-B-C
Expected results in Active Sheet in col D-E-F,,,,
TopLeftCell is the ActiveCell
select a cell in columns D-E-F-G-H....and run this code
If MsgBox("Target Cell is...
" & Selection(1).Address, vbOKCancel) = vbCancel Then Exit Sub
Dim adr As String
adr = Selection(1).Address
If Range(adr).Column < 4 Then
MsgBox "wrong selection"
Dim r As Long, c As Long, x As Long, L As Long
r = Cells(Rows.Count, "A").End(xlUp).Row
c = ActiveSheet.UsedRange.Columns.Count
L = ActiveSheet.UsedRange.Rows.Count
If c < 4 Then c = 4
With Range(Cells(1, 4), Cells(L, c))
Range("A1").Resize(r, 3).Copy Range(adr)
Application.DisplayAlerts = False
For x = Range(adr).Row + r To Range(adr).Row + 2 Step -1
If Cells(x, Range(adr).Column) = Cells(x - 1, Range(adr).Column) Then
Union(Cells(x, Range(adr).Column), Cells(x - 1, Range(adr).Column)).Merge
If Cells(x, Range(adr).Column + 1) = Cells(x - 1, Range(adr).Column + 1) Then _
Union(Cells(x, Range(adr).Column + 1), Cells(x - 1, Range(adr).Column + 1)).Merge 'bbb
With Range(adr).Resize(r, 3)
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlCenter
Application.DisplayAlerts = True
- Go to the Start button.
- In the Search box, type "regedit" (without quotes) and press Enter.
- Look for the following registry key: "HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\ SQMClient\Windows\DisabledSessions".
- On the right window pane, delete the subkey: "Machine Throttling".
- Reboot your computer.
Another Safe way to Fix the Problem: Display the box to confirm and deliver message before running the code:
How to Fix Display the box to confirm and deliver message before running the code with SmartPCFixer?
1. Click the button to download Error Fixer . Install it on your computer. Run it, and it will scan your system. The errors will be shown in the scan result.
2. After the scan is done, you can see the errors and problems need to be repaired. Click Fix All.
3. When the Fixing part is done, your computer has been speeded up and the errors have been fixed
Related: Way to Update & Download SONY SVE14A2X1EH Wireless State Device driver,How to Update & Download SONY SVS1511X9RB Graphics Driver for D2 (Intel) v.9.17 - 220.127.116.1128,Method to Download SONY VGN-CR290N Realtek High Definition Audio Driver v.18.104.22.16833,Download SONY VGN-FS710/W Utilities DLL Update v.6.4.0.06290 driver,Method to Update & Download SONY VGN-NR460E/P Intel Graphics Media Accelerator Driver v.22.214.171.12447,How to Fix Error 0x0000c1f5 Solución?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error,Solution to ashoutxt.dll Missing Error,Solution to cxcore096.dll Missing Error,Where can I Find dsauth.dll File,How to Fix msde.dll Not Found Error,Best Method to Fix psizewizres.dll Error
Read More: [Solved] do i need to keep service pack 2 in program after getting service pack 3,Solution to Error: Disk manager,Troubleshoot:disk defragmenter Hangs at 35% and does nothing- does not give error message, works fine D:drive and worked fine before i used Perfectdisk 11 Error,[Solution] DISK CLEANUP NOT WORKING. OS VISTA HOME,Fast Solution to Error: Display Empty Cell When Data Not Present,Data validation question. Maintaining and updating named ranges.,Desktop Gadget Gallery on Windows 7,delete empty rows,Deleting a page and also how can I copy an exact page lay out on a new page,Date Formula for 1st Sunday of each Month (3rd to 9th)