Reputation: 79
how can I make the entry of a Label field in Excel Dynamic? What I want is, when I open up the excel file my username will show up on the dynamic label field. on a Excel 5.0 Dialog.
Upvotes: 0
Views: 1928
Reputation: 187
Use this to bind the value to username and Workbook_Open event. Just make sure you have the right name in "Label 1".
Private Sub Workbook_Open()
Worksheets("YourSheetName").Shapes("Label 1").TextFrame.Characters.Text = Environ("Username")
End Sub
Place it in VBA.Project ThisWorkbook
This where you find the name of the label:
Upvotes: 1
Reputation: 5450
Place this in the sheet specific module - this will dynamically change Label 1
's caption whenever something on the worksheet changes:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Shapes("Label 1").TextFrame.Characters.Text = Range("A1").Value
End Sub
Upvotes: 1