Hi, Paste the following code into the sheet module : Sub test() For Each sh In Me.Shapes If sh.DrawingObject.progID = "Forms.CommandButton.1" Then Var = sh.Name Var = Mid(sh.Name, 2, 1) If Left(sh.Name, 1) = "B" And Mid(sh.Name, 2, 1) > "0" And Mid(sh.Name, 2, 1) < "5" And _ Mid(sh.Name, 4, 1) > "0" And Mid(sh.Name, 4, 1) < "5" And Mid(sh.Name, 3, 1) = "C" And _ Len(sh.Name) = 4 Then sh.DrawingObject.Enabled = False End If End If Next sh End Sub
Regards. Daniel -----Message d'origine----- De : excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] De la part de deepu Envoyé : jeudi 23 juin 2011 17:00 À : MS EXCEL AND VBA MACROS Objet : $$Excel-Macros$$ How To Change Properties Of Form Controls Hi Guy's, I've 20 command buttons on a worksheet to be used for different purposes. I've write a code to disable and enable all of them accordint to situations. All the buttons have a common naming standard, e.g. "B1C1","B1C2","B1C3","B1C4","B2C1","B2C2"..... I've tried with the following code.. For B = 1 to 4 For C=1 to 4 Me("B" & Format(B,"0") & "C" & Format(C,"0")).Enable=false Next C Next B But getting the run time error 438.. Can anyone help me?? Thanks Deepak -- ---------------------------------------------------------------------------- ------ Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel