+ Reply to Thread
Results 1 to 5 of 5

run-time error '91' object variable not set

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    run-time error '91' object variable not set

    I'm really feeling stupid right now because I can't figure out why I can't set a range to RowCount. I've used a similar code elsewhere without any problems. Any feedback would be appreciated.

    Private Sub cmdbutMakeEdit_Click()

    Dim RowCount As Range
    Dim RowCell As Integer
    Dim EditDrug As String

    Dim ws As Worksheet
    Dim ws3 As Worksheet
    Set ws = Worksheets("Sheet1")
    Set ws3 = Worksheets("Sheet3")

    EditDrug = ws3.Cells(1, 1).Value

    Set RowCount = Worksheets("Sheet1").Range("D1:D10000").Find(EditDrug, lookat:=xlPart) <----this keeps coming back as nothing

    RowCell = RowCount.Row

    If Not RowCount Is Nothing Then
    RowCell = RowCount.Row

    ws.Cells(RowCell + 10, 7).Value = txtboxDose.Value
    ws.Cells(RowCell + 10, 8).Value = cboRoute.Value
    ws.Cells(RowCell + 10, 9).Value = cboFrequency.Value
    MsgBox "Medication has been edited"

    End If

    Me.txtboxDose.Enabled = False
    Me.txtboxDose.Visible = False
    Me.txtboxDose.Value = ""
    Me.cboRoute.Enabled = False
    Me.cboRoute.Visible = False
    Me.cboFrequency.Enabled = False
    Me.cboFrequency.Visible = False
    Me.cboAdditionalDrugInfo.Enabled = False
    Me.cboAdditionalDrugInfo.Visible = False
    Me.cboPage1Meds.Value = ""

    End Sub

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: run-time error '91' object variable not set

    can you post wb?
    ps: wrap your code ino code tags
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    11-15-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: run-time error '91' object variable not set

    what do you mean by "post wb"?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,758

    Re: run-time error '91' object variable not set

    post wb = Attach a sample workbook.

    When you are in Advanced reply, click on the paperclip to open the upload window.

    View Pic

    Code tags: See my signature, and also:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,758

    Re: run-time error '91' object variable not set

    There is no way to diagnose this without seeing the data. It's coming back as Nothing because the value EditDrug is not found in column D. Is there some reason you think it should be found?
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1