+ Reply to Thread
Results 1 to 6 of 6

Create a script to find matching values based on criterias

  1. #1
    Registered User
    Join Date
    11-27-2023
    Location
    Vienna
    MS-Off Ver
    Office 365
    Posts
    12

    Create a script to find matching values based on criterias

    Hi everyone,

    I started to create a macro in VBA to find matching value based on 2 criterias

    the code:

    Please Login or Register  to view this content.
    Capture.PNG
    2023-11-27_11-19-22.jpg

    The code finds now the value of C13 on the other sheet in range A4:A54 but gives the result constantly of B4:B54 and not taking into consideration the other criteria which is finding A13 in row A3:L3

    Any suggestion?

    Thank you in advance!
    Last edited by AliGW; 11-27-2023 at 07:15 AM. Reason: Code tags added - please review the forum guidelines.

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Create a script to find matching values based on criterias

    Hi
    And welcome on board
    Try this method
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-27-2023
    Location
    Vienna
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Create a script to find matching values based on criterias

    Hi,

    thank you for both, welcoming and for the solution!
    Works well and very elegant!

  4. #4
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Create a script to find matching values based on criterias

    You Are very welcome.
    And thank you for the feedback.
    Be happy and safe.

  5. #5
    Registered User
    Join Date
    11-27-2023
    Location
    Vienna
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Create a script to find matching values based on criterias

    Hi mohadin,

    sorry to open up this topic, but right now I have the problem with this exact example.

    Sub FindAndCrossCells()
    Dim kalkulatorSheet As Worksheet
    Dim gltSheet As Worksheet
    Dim KalkulatorRange As Range
    Dim GLTRange As Range
    Dim resultRange As Range
    Dim r&, c&
    Set kalkulatorSheet = ThisWorkbook.Sheets("Kalkulator")
    Set gltSheet = ThisWorkbook.Sheets("GLT")
    Set KalkulatorRange = kalkulatorSheet.Range("C13")
    Set GLTRange = gltSheet.Range("A4:A54")
    Set resultRange = kalkulatorSheet.Range("A13")

    r = GLTRange.Find(KalkulatorRange, , , 1).Row
    c = gltSheet.Range("A3:l3").Find(resultRange, , , 1).Column
    MsgBox gltSheet.Cells(r, c)


    End Sub

    When I first used this code, it worked perfectly. Now I changed data on sheet "GLT" (structure remained the same) and I continously get Error 91 for row
    r = GLTRange.Find(HomeRange, , , 1).Row
    c = gltSheet.Range("A3:CT254").Find(resultRange, , , 1).Column

    I really can't find the mistake, because all objects seemed to be declared correctly and I haven't changed anything else on the sheets.

    Do you have any idea, what might be the problem?

    Thank you!

  6. #6
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    515

    Re: Create a script to find matching values based on criterias

    Hello @Medoweb. You can attach an example file with your code according to the forum rules. See the yellow banner at the top of this page to see how you can do this. With an example file there is a great chance to get help with your question. Good luck.
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

+ 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. Find matching value from 2 Columns based on several lokup values
    By FlamingoCup in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 03-30-2020, 09:30 AM
  2. Finding a date based on two matching criterias.
    By might_be_high in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-03-2017, 09:53 PM
  3. Create multiple templates based on matching values
    By ashishmehraitc09 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2017, 09:15 AM
  4. [SOLVED] Return Value or Values matching two criterias
    By ChipsSlave in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2017, 03:13 AM
  5. find top 10 values based on multiple criterias
    By saurabhlotankar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-27-2014, 01:47 AM
  6. Filling values by matching two criterias
    By Zaid in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2013, 10:15 AM
  7. Centralized Excel sheet and a way to find values based on 3 criterias
    By Tim Georgiev in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-05-2012, 08:17 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