+ Reply to Thread
Results 1 to 9 of 9

Combining two VBA projects – Error

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Combining two VBA projects – Error

    Hi,

    I have been working on part of the code for my spreadsheet and it works fine in the spreadsheet “Databaseform” however when I copied the code to my master spreadsheet “Paul_PartLocDBCombo” it does not work, I get the error:

    Method ‘range’ of object ‘_worksheet’ failed

    The code is then highlighted

    Please Login or Register  to view this content.
    Meaning this part is incorrect but I don’t know why? If it works on the other spreadsheet does anyone have any suggestions why it doesn’t work on this one?

    Any guidance will be appreciated as its driving me crazy

    To work it: go to Databaseform and press start. Enter 7mm in the product field and press find all. It will then return all the matching results in the userform. Its this I want to try and achieve on the other spreadsheet when the button find label is pressed.
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Please stop cross posting, lest your threads become ignored or deleted.

    Your second range reference is not qualified.

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Apologies for Cross Posting, the post has now been closed,the cross post is here http://www.ozgrid.com/forum/showthread.php?t=86165

    It was suggested that I use:

    Please Login or Register  to view this content.
    However when using this I still get an error (run time error 91). This is the Code that is highlighted as the problem:
    Please Login or Register  to view this content.
    The full Code is:
    Please Login or Register  to view this content.
    If any has any suggestions I would REALLY appreciate it. I have literally spent hours on this.

    I do not necessary need a filter. I would like it to first match what is in text box 1 within the range (the range is on sheet “wksPartData” in cells A:O) and then return the results from the search into list box 1, ideally the search would only return results where column O is greater 40 in value.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The error is descriptive: Object variable or With block variable not set. rFilter has not been set.

    I do not necessary need a filter. I would like it to first match what is in text box 1 within the range (the range is on sheet “wksPartData” in cells A:O) and then return the results from the search into list box 1
    You could use the Find method, but ... if you find what's in textBox1, isn't what you find going to be what you already have?

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Hi,

    I dont mind which method I use but I dont know how to write the code as I am a complete newbie.

    When it searches it will search the text box and then I need it to return all the matches from a different sheet, there could be approx 10 different matches, each with different "yields".

  6. #6
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    One other thing I have noticed is that when the command button “start” is moved to another worksheet then I get the same VBA error. I think if I crack this then I may have answered my problem above. Any suggestions?

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Does a Command Button only work in its original sheet

    I have read that a command button will only work in its original sheet. It was suggested to use a shape rather than a command button but this didnt work.

    Is this true and if so is there a workaround?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Paul, can you go back to first principles and explain, top down, what you're trying to do? An example workbook would be helpful.

  9. #9
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689
    Hi,

    I have managed to find a work around on what I am trying to achieve, its not ideal but it will work.

    I have attached the spreadsheet with it working.

    My main problem now is that the start button has to be kept on its orignal worksheet. If I move it to another location it no longer works.

    Any thoughts?
    Attached Files Attached Files

+ 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