2

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
6
  • Where does the error occur? Have you tried breakpoints / stepping through the code, etc? Commented Jul 2, 2013 at 13:56
  • Is this ActiveSheet("Label").Caption = sType correct? Your other Label references have numbers. Commented Jul 2, 2013 at 13:59
  • at Label 1 and all the below lines I get the same error 438 and do not know how to solve it Commented Jul 2, 2013 at 14:01
  • yes it is, even if I put this line in comment I still get the same error message for the one below. I am using the right inputing method? Commented Jul 2, 2013 at 14:02
  • 1
    what are .cbztest. and .cbzPressure.? I think you may be getting the error as the Range class isnt properly overriden Commented Jul 2, 2013 at 14:51

1 Answer 1

1

Try ActiveSheet.TextBox1.Text = sWname and so on

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.