+ Reply to Thread
Results 1 to 7 of 7

if statement bringing up error

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    Derbyshire, England
    MS-Off Ver
    2013
    Posts
    18

    if statement bringing up error

    Can anyone tell me why this if statement isn't working for me please?

    If Range("B6").Value - Range("B5").Value = Windows("Raw data Macro.xlsm").Range("A3").Value Then
    [statement to continue copying]
    Else
    End If

    “object doesn’t support this property or method"

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: if statement bringing up error

    Does the file need to be open to do this?
    Has the Windows() Object been loaded?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: if statement bringing up error

    Hi,

    A Window doesn't have a Range property. You need to access a worksheet- perhaps thus
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    01-06-2016
    Location
    Derbyshire, England
    MS-Off Ver
    2013
    Posts
    18
    Quote Originally Posted by Special-K View Post
    Does the file need to be open to do this?
    Has the Windows() Object been loaded?
    Yes and yes

  5. #5
    Registered User
    Join Date
    01-06-2016
    Location
    Derbyshire, England
    MS-Off Ver
    2013
    Posts
    18

    Re: if statement bringing up error

    That works, Thankyou

  6. #6
    Registered User
    Join Date
    01-06-2016
    Location
    Derbyshire, England
    MS-Off Ver
    2013
    Posts
    18

    Re: if statement bringing up error

    That if statement is looking at the difference between two dates in a .csv file (in date format dd/mm/yyyy hh:mm), in cells B6 and B5 and comparing it to a 20 second value (in number format 0.000231481481023366) in the "Raw data Macro.xlsm"

    I want it to skip the statement below it if it does not equal to 20 seconds. However it's running through the statement every time, even when the time difference is 40 seconds. Any thoughts why this might be happening?

    The vba now looks like this:
    Please Login or Register  to view this content.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: if statement bringing up error

    Have you tested the values of the three cells as read by the code (not as you think they are)?

+ 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. Countif bringing back Value Error.
    By Cbirchfi in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 09-06-2016, 01:09 PM
  2. Button in a form keeps bringing up a Compile error
    By Kellise in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2016, 05:42 PM
  3. Help with userform code looping and bringing error
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-11-2015, 06:02 AM
  4. Macro code to show userform bringing runtime error 1004
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-11-2015, 02:59 AM
  5. Problem with simple IF statement and bringing over values
    By anoble1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-29-2014, 09:58 PM
  6. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  7. Replies: 4
    Last Post: 05-16-2012, 05:33 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