ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro assignment to button gets reassigned (https://www.excelbanter.com/excel-programming/273602-re-macro-assignment-button-gets-reassigned.html)

John Gittins

Macro assignment to button gets reassigned
 
can you show the code originally assigned to the button so we can check it?

"Rob" wrote in message
...
Very bizzare behaviour. I have a button with a macro (VBA
Procedure I had written) assigned to it. For some unknown
reason, the assinged macro has changed and now references
a Named Reference! And in some cells I use the vlookup
function with a Named Reference, it replaced that Named
Reference with a VBA Procedure I had written.

Any idea what is going on here? I have Excel 2000,
9.0.2720.

Thanks!

Rob





Rob[_11_]

Macro assignment to button gets reassigned
 
John,

In the spreadsheet I had every use of a Named Reference
and every macro/VBA assignment get changed. In some cases
where I had referenced a VBA Proc, it got replaced with a
Named Reference!

An example of one change was where one Named Ref got
swapped with another:
I had a vlookup that originally had:
=VLOOKUP(A2,HourDetail,17,FALSE)

But it got changed to:
=VLOOKUP(A2,LunchHours,17,FALSE)
where LunchHours was a different named reference.

In another case, I had code to freeze values on a
spreadsheet get changed to another procedure. In that
case, the original code (ClearLunch) was changed to
(SetWorksheet). The code for both is shown below.

Thanks for taking the time to look at this.

Rob

Sub ClearLunch()
Dim iAnswer, iNumrows As Integer
Dim sAreYouSure, sFirstRegionEnd, sSecondRegionEnd As
String
sAreYouSure = "Are you sure you want to clear the
lunch values?"
iAnswer = MsgBox(sAreYouSure, vbYesNo, "Confirm")
If iAnswer = vbYes Then
ActiveSheet.Unprotect
iNumrows = Range("A1").CurrentRegion.Rows.Count
sFirstRegionEnd = "G" & iNumrows
Range("C4", sFirstRegionEnd).ClearContents
sSecondRegionEnd = "M" & iNumrows
Range("I4", sSecondRegionEnd).ClearContents
ActiveSheet.Protect
End If
End Sub

Sub SetWorksheet()
Dim sAreYouSure As String
Dim iAnswer As Integer
'This procedure will convert all formulas to their
values.
'Get the name of the sheet, then confirm with the user
that they are
'about to freeze the calculated values on the payroll
worksheet.
ActiveSheet.Unprotect
Cells.Select
sAreYouSure = "Are you sure you want to freeze the
cacluated values on this payroll sheet?"
iAnswer = MsgBox(sAreYouSure, vbYesNo, "Confirm")
If iAnswer = vbYes Then
Selection.Copy
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End If
ActiveSheet.Protect
Application.CutCopyMode = False
Range("A1").Select
End Sub
-----Original Message-----
can you show the code originally assigned to the button

so we can check it?

"Rob" wrote in message
...
Very bizzare behaviour. I have a button with a macro

(VBA
Procedure I had written) assigned to it. For some

unknown
reason, the assinged macro has changed and now

references
a Named Reference! And in some cells I use the vlookup
function with a Named Reference, it replaced that Named
Reference with a VBA Procedure I had written.

Any idea what is going on here? I have Excel 2000,
9.0.2720.

Thanks!

Rob




.



All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com