1. How to make Button Size as a Cell Size?
2. How to freeze the button, or any othe control from seeing its "right click" menu?
Thanks in advance.
1. How to make Button Size as a Cell Size?
2. How to freeze the button, or any othe control from seeing its "right click" menu?
Thanks in advance.
Re: Button Size as s Cell Size?
Hi Jonny
Best way is to use a CommandButton from the Control Toolboz Toolbar. Then right click on it and choose Properties and set the Width Property to the cells Column Width and the Height Property to the cell Row Height.
You can use a CommandButton from the Forms toolbar and size it manualy and set it's Object Positioning to "Move and size with cell". Then Protect the Worksheet to stop the right click action.
Re: Button Size as s Cell Size?
Here's a quick bit of code which resizes a control according to the dimensions of a cell you refer to ...
Should point you in the right direction
Sub a()
Dim s1 As String
Dim I1 As String
Dim w As Double
Dim h As Double
s1 = "Sheet1" 'name of sheet you wish to use...
Sheets(s1).Select
10
e = 0
I1 = InputBox("Which Cell Do You wish to use as size template? Enter as cell ref = ie A1", "Cell Dimension", "A1")
If I1 = Cancel Then GoTo 10
On Error GoTo InvalidRange:
With Range(I1)
w = .Width
h = .Height
End With
If e = 1 Then GoTo 10
Dim obj As Object
For Each obj In ActiveSheet.OLEObjects
If obj.OLEType = 2 Then
With obj
.Width = w
.Height = h
End With
End If
Next obj
Exit Sub
InvalidRange:
MsgBox "Invalid Cell Reference Entered", vbCritical, "Error"
e = 1
Resume Next
End Sub
Display More
Re: Button Size as s Cell Size?
Dave Hawley & lasw10, thank you a lot for a good answers.
Nice to learn smth new that may assist in your work.
Don’t have an account yet? Register yourself now and be a part of our community!