+ Reply to Thread
Results 1 to 9 of 9

Trouble Setting A Range

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Trouble Setting A Range

    My code has just recently stopped worked breaking with an "Object variable or With block variable not set." at the line in red.

    Please Login or Register  to view this content.
    My guess is the 'set ref_date' reference has failed. But I have no idea why?

    tdate = 1/3/2019
    ws_target is a recognized worksheet
    ws_schedule is also a recognized worksheet referring to a worksheet in a second open workbook
    Column B, row 2 holds the date 1/3/2019, although formatted as ddd dd-mm.
    red_date is defined as a range

    Is anyone able to offer some support?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,681

    Re: Trouble Setting A Range

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Trouble Setting A Range

    Thank you Trevor. It will take me some time and effort to censor the data to release publically. It involes two different workbooks.

    I have discovered upon returning home that this error cannot be replicated on my home computer (where the code had been written). The error seems to be unique to my office computer.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,681

    Re: Trouble Setting A Range

    It doesn't need to be the real workbook or an edited version. Just a worksheet with the data that is causing the problem.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,595

    Re: Trouble Setting A Range

    Quote Originally Posted by Jenn68 View Post

    tdate = 1/3/2019
    ws_target is a recognized worksheet
    ws_schedule is also a recognized worksheet referring to a worksheet in a second open workbook
    Column B, row 2 holds the date 1/3/2019, although formatted as ddd dd-mm.
    red_date is defined as a range
    1) Try xlFormulas instead of xlValues
    Please Login or Register  to view this content.
    2) Try using Match method
    Please Login or Register  to view this content.
    Last edited by jindon; 03-13-2019 at 07:55 PM.

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

    Re: Trouble Setting A Range

    If you want to find the row try using Application.Match instead of Find.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Trouble Setting A Range

    I've went the route of using the Match function. I've used it in most other similar situations in my project, I don't know why I didn't it this case. Seems to have taken care of the problem.
    Thanks all!

  8. #8
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Trouble Setting A Range

    Quote Originally Posted by TMS View Post
    It doesn't need to be the real workbook or an edited version. Just a worksheet with the data that is causing the problem.
    Oh, ok. I understand now. Thanks Trevor. Next time!

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,681

    Re: Trouble Setting A Range

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Trouble setting workbook variable
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2013, 05:52 AM
  2. [SOLVED] Trouble Setting Range wit h a Varaible Column
    By CGriffiths1214 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2013, 12:26 PM
  3. Using SumIf in VBA - Having trouble setting the condition
    By Aquila2011 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2012, 05:27 AM
  4. Trouble Setting a Range
    By CJ944 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2012, 10:53 AM
  5. Trouble Setting a cell to a value
    By jubi23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2007, 02:52 PM
  6. trouble setting plotarea size
    By Albert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2006, 05:45 PM
  7. Trouble setting visible property for PivotItems
    By ridawg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2006, 10:10 AM
  8. [SOLVED] Trouble setting total for on chart
    By Mark in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-10-2005, 11:06 PM

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