Hi All,
I've got a couple of sheets with a lot of buttons in them. Some of these buttons have the wrong dimensions. What I want to do is run a macro so that every button gets the same dimensions as a given cell. I've found the following macro:
Sub ButtonSize_as_CellSize()
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 = Application.InputBox("Which Cell Do You wish to use as size template? Enter as cell ref = ie A1", "Cell Dimension", "A1")
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
But this doesn't do anything (no error, but also no changes). If I step through the macro it jumps from line "For Each obj In ActiveSheet.OLEObjects" to line "Exit Sub". So it seems there are no OLEObjects in the sheet. But there are about 100 buttons in the sheet.
Could a button be anything else than an OLEObject? And if so, is there a way I can change this macro to do what I want it to do?
Bookmarks