I have two macros that work great independently, but for some reason I can't get them to work together.
Macro 1:
On worksheet 1, I have a data validation drop down list in cell F2. Any time the cell is selected (regardless of content), I want it to run the same macro (the macro is named "Size"). The code I am using for that, and where I suspect the problem is, is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("F2")
Call Size
End Sub
Macro 2:
This macro is the one that I have the code above calling. It works great when I call it manually, or attach it to a button, but for some reason I always get error messages when I run it from the macro above.
Sub Size()
ActiveSheet.Unprotect
Set myRange = ActiveCell
Range("B10").Select
Selection.Copy
Range("P10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("10:10").EntireRow.AutoFit
Range("B20").Select
Selection.Copy
Range("P20").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("20:20").EntireRow.AutoFit
Range("B24").Select
Selection.Copy
Range("P24").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("24:24").EntireRow.AutoFit
Range("B26").Select
Selection.Copy
Range("P26").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("26:26").EntireRow.AutoFit
Range("B30").Select
Selection.Copy
Range("P30").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("30:30").EntireRow.AutoFit
Range("J30").Select
Selection.Clear
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
myRange.Select
End Sub
Display More
The error says: "the cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password."
However, when I unprotect the sheet, and delete all the .protect / .unprotect tags from the code - the macro runs, but right at the end it freezes excel. I have no idea what the solution is - any help would be greatly appreciated.
Thanks,
D