Locking Macro-Assigned Pictures so not to corrupt file

Dom2012

Board Regular
Joined
Oct 2, 2006
Messages
77
Hi,

I have picture buttons I have assigend macros to. The first, when clicked on, adds a row. The second deletes a row.

If the user puts the cursor in the wrong cell before clicking on either 'button', they delete the wrong row and corrupt the file. They could only recover it by closing the file without saving changes, and re-opening it - which is not an ideal solution.

Is there a way to link the macro-assigned picture buttons to specific cells so that if the user has the cursor in the wrong cell, the buttons won't work and a message tells them what to do? The soltion would also have to refer to non-relative cells since, as a row is added or deleted, it changes the cell's number by +/- one.

Thanks,

Dom

PS. If this is not clear, let me know and I'll explain better!
 
So it would look like this...? Having something in the cells above it will actually be useful - it'll make something else work too.

Cells(1, 1).End(xlDown).Select
ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-1, 0).Range("A1:AP1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1:AP1").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=False
ActiveCell.Offset(-2, 0).Range("A1:AP1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1:AP1").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=False
ActiveCell.Offset(2, 0).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=SUM(R[-1]C)"
ActiveCell.Offset(-2, 2).Range("A1:C1").Select
End Sub
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Strangely, it made it duplicate a completely different cell several rows and columns away from the work area. Any idea why that might be?
 
Upvote 0

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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