+ Reply to Thread
Results 1 to 9 of 9

Macro issue: Object variable or with block variable not set error

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    portland, oregan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Lightbulb Macro issue: Object variable or with block variable not set error

    I'm trying to populate a matrix from three columns in a worksheet. My code is supposed to find a value in the first column, match it to the y-axis, then search the second column for a value, match it to a column header in the x-axis, and then paste the value from the third column in the cell activated by the row/column match. Does anyone see what's wrong with my code? I keep getting a "object variable or with block variable not set" error:

    HTML Code: 
    I originally posted this in the general forum, but decided to move it here...Sorry I goofed on where to post it
    Attached Images Attached Images
    Last edited by utgjmb1; 07-25-2013 at 02:52 PM.

  2. #2
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Macro issue: Object variable or with block variable not set error

    For one thing, you have several undefined variables. I suggest you use Option Explicit, and the compiler will help identify those issues.

  3. #3
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Macro issue: Object variable or with block variable not set error

    cannot test it as there are a lot of veriables used here that i am asuming are defigned elsware (e.g. originalString)
    when you get the error select debug and tell us what it highlights as the problem section

    as a quick fix check though use
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-18-2013
    Location
    portland, oregan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro issue: Object variable or with block variable not set error

    Thanks! No, they weren't defined anywhere else just because I didn't think they needed to be I'm sorry I'm a complete newbie to VBA so I'm lost. If this is the only code I have for the two worksheets below, what other variable need to be defined?

    WS1.jpgWS2.jpg

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro issue: Object variable or with block variable not set error

    Can we see the rest of the code?

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    07-18-2013
    Location
    portland, oregan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro issue: Object variable or with block variable not set error

    Unfortunately, this is all of my code, but I'm edit my post to include the worksheets

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro issue: Object variable or with block variable not set error

    What is WBook (or is it WBook1) meant to refer to?

  8. #8
    Registered User
    Join Date
    07-18-2013
    Location
    portland, oregan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro issue: Object variable or with block variable not set error

    Quote Originally Posted by Norie View Post
    What is WBook (or is it WBook1) meant to refer to?
    That line is accidentally in there.. you see, these worksheets are actually two different workbooks, but I combined them into one workbook manually because it was just too difficult for me to refer to them in my code, so I just gave up and started writing the code as if they were in the same workbook. I guess I'll just copy and move the worksheets so they're together every time I run this report

  9. #9
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Macro issue: Object variable or with block variable not set error

    This is basically your code and should run without errors.
    Please Login or Register  to view this content.
    Edit: however I can't see what it will do other than make the cell bellow activecell blank.
    Last edited by Leon V (AW); 07-29-2013 at 06:10 AM.

+ 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. Replies: 1
    Last Post: 07-24-2013, 02:45 PM
  2. [SOLVED] Excel VBA error code 91: Object variable or with block variable not set
    By wilnexpc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-24-2013, 11:46 AM
  3. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  4. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  5. Find Method error: -Object variable with block set variable not set
    By bambino_32 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-02-2010, 01:18 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