Skip to main content

Posts

Showing posts with the label Dynamically Draw Rectangle in UserForm

How to Dynamically Change Userform's Control properties from Excel Sheet using Excel VBA

How to Draw Rectangle in VBA using Excel Data This is an exclusive request from Phil. If you find it interesting, I am more glad. The idea is to draw/resize a rectangle in userform based on values from Excel sheet. I am using a label control for rectangle. Let us add a label control to userform and name it as LabelRect To the WorkSheet_Change event of the required sheet add the following event Private Sub Worksheet_Change(ByVal Target As Range) Dim oLbl As MSForms.Label Set oLbl = UserForm1.LabelRect If Target.Address = "$B$1" Or Target.Address = "$B$2" Then If IsNumeric(Range("B1").Value) = True Then oLbl.Height = Range("B1").Value If IsNumeric(Range("B2").Value) = True Then oLbl.Width = Range("B2").Value oLbl.BackColor = vbGreen UserForm1.Show (False) End If End Sub The code will get executed when there is a change in Value in column B1 and B2. Hence the label in the userform will be adjusted accordin...

Facebook

Facebook Recommendations

Followers


Web Designing In Karachi



Haroof.com


Politics blogs

My Zimbio

Email Subscribe

Enter your email address:

Watch online Live TV

Labels

Show more