Advertisement
Advertisement


Excel VBA Run Time Error '424' object required


Question

I am totally new in VBA and coding in general, am trying to get data from cells from the same workbook (get framework path ...) and then to start application (QTP) and run tests.

I am getting this error when trying to get values entered in excel cells:

Run Time Error '424' object required

I believe I am missing some basic rules but I appreciate your help. Please see below the part of code in question:

Option Explicit

Private Sub RunTest_Click()

    Dim envFrmwrkPath As Range
    Dim ApplicationName As Range
    Dim TestIterationName As Range
    'Dim wb As Workbook
    'Dim Batch1 As Worksheets
    Dim objEnvVarXML, objfso, app As Object
    Dim i, Msgarea

    Set envFrmwrkPath = ActiveSheet.Range("D6").Value ' error displayed here
    Set ApplicationName = ActiveSheet.Range("D4").Value
    Set TestIterationName = ActiveSheet.Range("D8").Value
2014/01/26
1
19
1/26/2014 1:52:49 AM


Simply remove the .value from your code.

Set envFrmwrkPath = ActiveSheet.Range("D6").Value

instead of this, use:

Set envFrmwrkPath = ActiveSheet.Range("D6")
2018/06/29

You have two options,

-If you want the value:

Dim MyValue as Variant ' or string/date/long/...
MyValue = ThisWorkbook.Sheets(1).Range("A1").Value

-if you want the cell object:

Dim oCell as Range  ' or object (but then you'll miss out on intellisense), and both can also contain more than one cell.
Set oCell = ThisWorkbook.Sheets(1).Range("A1")
2019/08/30

Private Sub CommandButton1_Click()

    Workbooks("Textfile_Receiving").Sheets("menu").Range("g1").Value = PROV.Text
    Workbooks("Textfile_Receiving").Sheets("menu").Range("g2").Value = MUN.Text
    Workbooks("Textfile_Receiving").Sheets("menu").Range("g3").Value = CAT.Text
    Workbooks("Textfile_Receiving").Sheets("menu").Range("g4").Value = Label5.Caption

    Me.Hide

    Run "filename"

End Sub

Private Sub MUN_Change()
    Dim r As Integer
    r = 2

    While Range("m" & CStr(r)).Value <> ""
        If Range("m" & CStr(r)).Value = MUN.Text Then
        Label5.Caption = Range("n" & CStr(r)).Value
        End If
        r = r + 1
    Wend

End Sub

Private Sub PROV_Change()
    If PROV.Text = "LAGUNA" Then
        MUN.Text = ""
        MUN.RowSource = "Menu!M26:M56"
    ElseIf PROV.Text = "CAVITE" Then
        MUN.Text = ""
        MUN.RowSource = "Menu!M2:M25"
    ElseIf PROV.Text = "QUEZON" Then
        MUN.Text = ""
        MUN.RowSource = "Menu!M57:M97"
    End If
End Sub
2014/06/13