BoShibh قام بنشر يونيو 20, 2023 قام بنشر يونيو 20, 2023 السلام عليكم ورحمة الله وبركاته .. اخواني احتاج مساعدتكم في كود يظهر ويخفي لي صفوف محدده عن طريق زر Toggle انا صممته ( سحب يمين ويسار ) ولكن الكود يظهر اخطا كثيرة Sub ToggleButto() Dim ws As Worksheet Dim xCells As String xCells = "12" 'change this to the row numbers Set ws = ThisWorkbook.ActiveSheet With ws 'TOGGLE "ON" If ToggleButton1.Value = True Then Application.ActiveSheet.Rows(xCells).Hidden = "True" 'update textbox value .Shapes("txtboxOnOff").TextFrame.Characters.Text = "OFF" 'update textbox alignment .Shapes("txtboxOnOff").TextFrame.HorizontalAlignment = xlHAlignRight 'update button background color .Shapes("ToggleButton").Fill.ForeColor.RGB = RGB(232, 27, 34) 'update radio button location .Shapes("radioButton").Left = .Shapes("ToggleButton").Left + .Shapes("ToggleButton").Width - .Shapes("radioButton").Width - 5 Else 'TOGGLE "OFF" ToggleButton1.Value = True Application.ActiveSheet.Rows(xCells).Hidden = "False" .Shapes("txtboxOnOff").TextFrame.Characters.Text = "ON" .Shapes("txtboxOnOff").TextFrame.HorizontalAlignment = xlHAlignLeft .Shapes("ToggleButton").Fill.ForeColor.RGB = RGB(117, 199, 1) .Shapes("radioButton").Left = .Shapes("ToggleButton").Left + 5 End If End With Set ws = Nothing End Sub مرفق لكم ملف العمل CoCo.xlsm
أفضل إجابة lionheart قام بنشر يونيو 20, 2023 أفضل إجابة قام بنشر يونيو 20, 2023 Try this code Sub ToggleButton_ON_OFF() Const ONKEY As String = "On", OFFKEY As String = "Off" Dim ws As Worksheet, shOnOff As Shape, shToggle As Shape, shRadio As Shape, s As String Set ws = ActiveSheet With ws Set shOnOff = .Shapes("txtboxOnOff") Set shToggle = .Shapes("ToggleButton1") Set shRadio = .Shapes("radioButton") End With With shOnOff s = .TextFrame.Characters.Text .TextFrame.Characters.Text = IIf(s = ONKEY, OFFKEY, ONKEY) ws.Rows("12").Hidden = (s = OFFKEY) .TextFrame.HorizontalAlignment = IIf(s = ONKEY, xlHAlignLeft, xlHAlignRight) shToggle.Fill.ForeColor.RGB = IIf(s = ONKEY, RGB(232, 27, 34), RGB(117, 199, 1)) shRadio.Left = shToggle.Left + IIf(s = ONKEY, shToggle.Width - shRadio.Width - 5, 5) End With End Sub 5
الردود الموصى بها
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.