+ Reply to Thread
Results 1 to 7 of 7

"run time error 91" with form

Hybrid View

  1. #1
    Registered User
    Join Date
    10-26-2011
    Location
    daska, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    46

    "run time error 91" with form

    dear I receive error " run time error 91" + "object variable or With Block Variable not set in line # 7. Please check my code as follow,

    Private Sub ComboBox3_Change()
    Dim c As Range
    Dim FindMe As Double
    If Flag = True Then Exit Sub
    FindMe = Val(Me.ComboBox3.Text)
    Set c = Sheets("Customers").Columns(2).Find(FindMe, LookIn:=xlValues)
    Me.TextBox1.Text = c.Offset(0, 1).Value

    End Sub

    I am getting error Me.TextBox1.Text = c.Offset(0, 1).Value
    line # 7. Please help me

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: "run time error 91" with form

    does Me.TextBox1.Text exist?
    try using Me.TextBox1.value

    oh and can you please wrap your code in tags else you will get in trouble!

    select your code and then click # on the tool bar
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    10-26-2011
    Location
    daska, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: "run time error 91" with form

    Private Sub ComboBox3_Change()
     Dim c As Range
     Dim FindMe As Double
     If Flag = True Then Exit Sub
     FindMe = Val(Me.ComboBox3.Text)
     Set c = Sheets("Customers").Columns(2).Find(FindMe, LookIn:=xlValues)
    Me.TextBox1.Value = c.Offset(0, 1).Value
    
     End Sub
    I tried but same erroe

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: "run time error 91" with form

    Check that something was actually found...
    
     Set c = Sheets("Customers").Columns(2).Find(FindMe, LookIn:=xlValues)
    
     If Not c in Nothing then
         Me.TextBox1.Value = c.Offset(0, 1).Value
     Else
         '// Some kind of error message
     End If

  5. #5
    Registered User
    Join Date
    10-26-2011
    Location
    daska, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: "run time error 91" with form

    its give compile and syntax error on line
    If Not c in Nothing then

  6. #6
    Registered User
    Join Date
    10-26-2011
    Location
    daska, Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: "run time error 91" with form

    thanks its ok and working it was typing mistake

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: "run time error 91" with form

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Assign Categories for Time of Day: "Morning", "Afternoon", "Evening"
    By long_shanks in forum Excel General
    Replies: 3
    Last Post: 06-11-2013, 02:59 AM
  2. Run-time error "1004" Application defined or object-define-error
    By josros60 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-21-2013, 01:14 PM
  3. Excel 2010 (Run-time error '13' type mismatch) "Debug" and "Continue" Grayed out.
    By Jeronimo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2012, 06:42 PM
  4. [SOLVED] VBA Excel 2007 : Autofit Merge Cells Error "Run-time error '13': Type Mismatch"
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2012, 04:10 PM
  5. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM

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