Reputation: 303
my workbook has two sheets, one which contains data and calculations, these data have been name using the name editor function. the second worksheet has a graph and a box consisting of a group of text boxes created using VBA control Active X option, this group of text boxes is to be imputted with values previously named abbove, below is a version of the code I usued, where label and TextBox are the neames of the text boxes and the other names the names of the defined cells. This code reports a 438 message error and would not input the labeled data in the box at the wanted location. How could I make it work so that the textboxes would display the named cells they are linked too?:
Private Sub Worksheet_Activate()
Dim sType As String
Dim sUnit As String
Dim sWellname As String
Dim sDate As String
Dim sMD As String
Dim sTVD As String
Dim sMud As String
Dim sPressure As String
Dim sEMW As String
sType = ThisWorkbook.Worksheets("sheet1").cbztest.Value
sUnit = ThisWorkbook.Worksheets("sheet1").cbzPressure.Value
sWname = ThisWorkbook.Worksheets("sheet1").Range("Wname").Value
sDate = ThisWorkbook.Worksheets("sheet1").Range("date").Value
sMD = Format(ThisWorkbook.Worksheets("sheet1").Range("MD").Value, "Standard")
sTVD = Format(ThisWorkbook.Worksheets("sheet1").Range("TVD").Value, "Standard")
sMW = ThisWorkbook.Worksheets("sheet1").Range("M_W").Value
sPressure = Round(ThisWorkbook.Worksheets("sheet1").Range("P_bar").Value, 1)
sEMW = Format(ThisWorkbook.Worksheets("sheet1").Range("EMW").Value, "Standard")
sType = ThisWorkbook.Worksheets("sheet1").cbztest.Value
ActiveSheet("Label").Caption = sType
ActiveSheet("TextBox1").Text = sWname
ActiveSheet("TextBox2").Text = sDate
ActiveSheet("TextBox5").Text = sMD
ActiveSheet("TextBox6").Text = sTVD
ActiveSheet("TextBox7").Text = sMW
ActiveSheet("TextBox8").Text = sPressure
ActiveSheet("TextBox9").Text = sEMW
ActiveSheet("Label8").Caption = sType & " EMW :"
ActiveSheet("Label13").Caption = sUnit
End Sub
Upvotes: 2
Views: 3392