Avatar of Wm Allen Smith
Wm Allen Smith

asked on 

VBA Object Error

Hi, '
I am hoping that  you can help me with an Object error. When I run this code:

Sub Part_G()

    Call EnterNames
    Dim rngNames As Range
    Dim cntNames As Integer
    With Range("A3")
    '----Put your code below this line----
  Dim A3 As Range
  Set rngNames = Sheet1.Range("A3")
  With Sheet1
        .Names.Add Name:="rngNames", RefersTo:=Range(rngNames.Offset(0, 0), _
    End With
    End With
With Range("A3")
  Set cntNames = Sheet1.Range("A3")
  With Sheet1
  cntNames = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
    MsgBox "Part G:  Number of names in the list = " & cntNames
    End With
End Sub

I get an object defined error on the "cntNames" variable . I am stumped. What am I missing?

Microsoft ExcelProgrammingVB ScriptVBA

Avatar of undefined
Last Comment

8/22/2022 - Mon