Object Required Error

mdo8105

Board Regular
Joined
Nov 13, 2015
Messages
83
I'm struggling on figuring out why this is giving me an object required error.
Code:
Private Sub CommandButton2_Click()Dim ws As Worksheet
Dim wb As Workbook
Dim Answer As String
Dim MyNote As String


'Place your text here
    MyNote = "Do any of your Providers have more than one specialty?"


Set wb = ThisWorkbook
Set ws = wb.Worksheets("Internal_Providers_&_Resources")


'''Find starting and ending range
srow = Application.WorksheetFunction.Match("S1", ws.Range("A:A"), 0) + 1
lrow = Application.WorksheetFunction.Match("En1", ws.Range("A:A"), 0) - 1
CA = Application.WorksheetFunction.CountA(ws.Range("E" & srow, "E" & lrow))
 ws.Select
        
        ws.Range("E" & srow, "E" & lrow).Select
        Set rng = Selection.SpecialCells(xlCellTypeBlanks)
        For Each cell In rng
        r = cell.Row


  SNew.TextBox73 = ws.Cells(r, 2).Value
  SNew.Show
        Next cell
End Sub

It's erroring out on this line SNew.TextBox73 = ws.Cells(r, 2).Value

For some reason this code works though and it pretty much mimics it:
Code:
 For r = 2 To ws.Cells(Rows.Count, 20).End(xlUp).Row  SpecialSAdd.TextBox73.Value = ws.Cells(r, 20).Value
  SpecialSAdd.TextBox74.Value = Trim(Application.WorksheetFunction.IfError(Application.WorksheetFunction.Index(Sheets("Internal_Providers_&_Resources").Range("E:E"), Application.WorksheetFunction.Match(ws.Cells(r, 20).Value, Sheets("Internal_Providers_&_Resources").Range("B:B"), 0)), ""))
  SpecialSAdd.Show
  
  
  Next r
The code that is working is called from another userform.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Code:
 SpecialSAdd.TextBox73.Value = ws.Cells(r, 20).Value
SpecialSAdd.Show
U have "SNEW" ? in there instead of "SpecialSAdd". HTH. Dave
 
Upvote 0
Thank you for your response Dave, the SNEW is another userform. Do I need declare the userform as an object?
 
Upvote 0
I figured out. I had the wrong userform called out on the Userform_Intialize. I just updated with ME.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top