raccoon588
Board Regular
- Joined
- Aug 5, 2016
- Messages
- 118
is there anyway to loop through all my lists boxes and make them the same size when the excel file is opened?
Private Sub CommandButton1_Click()
'Modified 1/29/2019 1:02:41 PM EST
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For Each OLEobj In ActiveSheet.OLEObjects
If OLEobj.progID = "Forms.ListBox.1" Then
With OLEobj.Object
.Font.Size = 24
.Clear
.List = Range("A1:A" & Lastrow).Value
.BackColor = vbGreen
.ForeColor = vbRed
.Width = 200
End With
End If
Next OLEobj
End Sub
With [COLOR=#ff0000]OLEobj[/COLOR]
.[COLOR=#ff0000]Object[/COLOR].Font.Size = 24
.[COLOR=#ff0000]Object[/COLOR].Clear
.[COLOR=#ff0000]Object[/COLOR].List = Range("A1:A" & Lastrow).Value
.[COLOR=#ff0000]Object[/COLOR].BackColor = vbGreen
.[COLOR=#ff0000]Object[/COLOR].ForeColor = vbRed
.Height = 200
.Width = 200
End With
It needs to be likeCode:With [COLOR=#ff0000]OLEobj[/COLOR] .[COLOR=#ff0000]Object[/COLOR].Font.Size = 24 .[COLOR=#ff0000]Object[/COLOR].Clear .[COLOR=#ff0000]Object[/COLOR].List = Range("A1:A" & Lastrow).Value .[COLOR=#ff0000]Object[/COLOR].BackColor = vbGreen .[COLOR=#ff0000]Object[/COLOR].ForeColor = vbRed .Height = 200 .Width = 200 End With