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

  • Home
  • SEARCH
  • 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 8140623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:13:25+00:00 2026-06-06T12:13:25+00:00

I have data stored in three columns of Excel Column A: Serial Number Column

  • 0

I have data stored in three columns of Excel

Column A: Serial Number
Column B: Date
Column C: Value (e.g. Cost)

I need to look for the Value (Column C) associated with a particular Serial Number (Column A) AND Date (Column B).

So for example, in the screenshot below, if I want to look for the Value associated with Serial number (T455) and Date (Dec 13, 2010), the value should be 8.

enter image description here

The only method I can come up with would be computationally inefficient, because I would go through ALL the cells each time I look for a value.

Is there a method, for example, that would limit the search area for a given serial number?

For example, if I am looking for a value for Serial Number T455, how can I limit the code to search for the date in Rows (6-13) and find the corresponding value in Column C, rather than searching the whole table?

Sub FindValue()

Dim S as String
Dim D as Date
Dim V as Integer

S = T455
D = Dec 13, 2010

for i = 1 to Range("A1").End(xldown).Row 

If Range("A" & i) = S And Range("B" & i) < Date - 7 And Range("B" & i) < Date + 7   Then
' This way i search a date range rather than a specific date

V = Range("C" & i).Value

End If

End Sub

I thought of While loops, or Lookup functions, but reached a dead end.

  • 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-06T12:13:27+00:00Added an answer on June 6, 2026 at 12:13 pm

    Non-VBA Solution that may be a lot easier and less of a headache.

    Column A consists of the formula, for A1 = “=B1&C1”

    Cell G1 formula can be seen in formula bar.

    enter image description here

    UPDATE
    Here is a VBA solution that will work faster, but there are some notes based on what you wrote that I am unsure of. Also, see some comments to help your code work more like you want it to.

    Sub FindValue()
    
    Dim S As String, D As Date, V As Integer, rngFound As Range, cel As Range
    
    S = "T455" 'needs quotes around the string
    D = "Dec 13, 2010" 'needs quotes around the date
    
    Dim wks As Worksheet
    Set wks = ActiveSheet
    
    With wks
    
         'always better to AutoFilter than Loop when you can!
        .UsedRange.AutoFilter 1, S
        .UsedRange.AutoFilter 2, ">" & D - 7, xlAnd, "<" & D + 7
    
        Set rngFound = Intersect(.UsedRange, .Columns(3)).SpecialCells(xlCellTypeVisible)
    
        'the only thing here is if you have a date range _
            'you may return more than one result _
            'in that case, I don't know what you want to do with all the V's
    
        If Not rngFound Is Nothing Then
            For Each cel In rngFound
                V = cel.Value
            Next
        End If
    
        .AutoFilterMode = False
    
    End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data stored as below in an MS Access database: Date User 20090101
I have some data that is stored in a TIMESTAMP(6) WITH TIMEZONE column in
I would like to rename a large number of columns (column headers) to have
I have data stored in comma delimited txt files. One of the columns represents
In my application I have generated a number of values (three columns, of type
I have a couple of scenarios: Need to read the value of a column
I have a file where a data structure containing 6 columns is stored side
In my application, I have three collection objects which store data. The data which
I currently have my data stored in this format : Word1 - Word2 -
I have stored data in hidden <input> tags, but it caused reduction in performance.

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.