Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:29:33+00:00 2026-06-04T21:29:33+00:00

I have a function that finds the current date in a range and returns

  • 0

I have a function that finds the current date in a range and returns the cell in which it’s found. I’m trying to use that cell’s position to calculate an offset within a subroutine. However, when I run the macro, I get objected required as an error. The function and the subroutine are as shown:

Function findCurrentDate() As Range
    Dim needle As Date
    Dim rng As Range
    needle = CLng(Date)
    Dim haystack As Range
    Dim search As Range
    Set haystack = Range("B3:B86")
    Set search = haystack.Find(needle, After:=haystack(1), _
                           LookIn:=xlValues, Lookat:=xlWhole, _
                           SearchOrder:=xlNext, MatchByte:=True)
End Function

Sub showFutureWeeklyHours()
    Dim wkday_row_offset As Integer
    Dim search As Range
    Set search = findCurrentDate()
    Set wkday_row_offset = search.Row
...
End Sub

This isn’t the complete subroutine, but it’s enough to reproduce the error. The list of dates are stored in cells B3:B86

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:29:34+00:00Added an answer on June 4, 2026 at 9:29 pm

    This wkday_row_offset is a number, not an object, so do not use Set.

    "This method returns Nothing if no match is found. The Find method does not affect the selection or the active cell."
    

    http://msdn.microsoft.com/en-us/library/ff839746.aspx

    You will need to check that something is returned before looking for the row property. Nothing does not have a row. A row is a number, not an object.

    Function findCurrentDate() As Range
        Dim needle As Date
        Dim rng As Range
        needle = CLng(Date)
        Dim haystack As Range
        Dim search As Range
        Set haystack = Range("B3:B86")
        Set search = haystack.Find(needle, After:=haystack(1), _
                               LookIn:=xlValues, Lookat:=xlWhole, _
                               SearchOrder:=xlNext, MatchByte:=True)
        Set findCurrentDate = search
    End Function
    
    Sub showFutureWeeklyHours()
        Dim wkday_row_offset As Integer
        Dim search As Range
        Set search = findCurrentDate()
    
        wkday_row_offset = search.row
    ''...
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have a function that finds a regex thingy, then replaces with php code.
I have a quick question here. I know that the cakePHP find('first') function returns
I have a python function defined as follows which i use to delete from
I need pure javascript function that finds the current opacity of HTML element and
Ok, I have a simple javascript function in a bookmarklet that finds all of
I have this working function that finds folders and creates an array. function dua_get_files($path)
I have a piece of VB code that dynamically finds my current file path
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.