+ Reply to Thread
Results 1 to 6 of 6

Need VBA to find Demerits code from different code segment

  1. #1
    Registered User
    Join Date
    02-24-2023
    Location
    sydney
    MS-Off Ver
    2019
    Posts
    39

    Need VBA to find Demerits code from different code segment

    Dear experts

    I have raw data which is need to validate as two category Demerits and Non Demerits. from different depends upon value of count.

    i have support sheet with set of segment if set of segment match with rawdata Merit code col J:J, result will be taken from same segment of result

    for e.g

    if tier is BSE first match sheet BSE if product ID is repeat twice and merit code SAP and SMB , check if these criteria match same segment in BSE sheet under Individual get result of segment result. Demertis and Non Demerits,
    if not match then result not found.

    i want result in B and L column
    B has to fill down how many times product repeat in A:A
    L result from sheets if Tier,Capcitivy,Merits Code.
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Need VBA to find Demerits code from different code segment

    try:
    Outcome is in sheet "Result"

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim lr&, i&, lookupRng As Rangecell As Rangecount&, f
    If Evaluate("=ISREF(Result!A1)"Then Sheets("Result").Delete
    Sheets
    ("Rawdata").Copy after:=Sheets("Rawdata")
    ActiveSheet.Name "Result"
    Columns(2).Insert
    lr 
    Cells(Rows.count"A").End(xlUp).Row
    For Each cell In Range("A2:A" lr)
        
    count WorksheetFunction.CountIf(Range("A2"cell), cell)
        
    cell.Offset(, 1).Value count
        Set lookupRng 
    Sheets(cell.Offset(, 8).Value).Columns(IIf(cell.Offset(, 9).Value "Individual"26))
        
    Set f lookupRng.Find(cell.Offset(, 10).Value)
        If 
    Not f Is Nothing Then cell.Offset(, 11).Value f.Offset(, 1).Value
    Next
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Registered User
    Join Date
    02-24-2023
    Location
    sydney
    MS-Off Ver
    2019
    Posts
    39

    Re: Need VBA to find Demerits code from different code segment

    Thanks alot sir for valuble time and quickly solved, i try to re-assign column nos in code with actual rawdata ,it give some error, i reform the column can u help me same code run on actual data
    Attached Files Attached Files

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Need VBA to find Demerits code from different code segment

    Try again:
    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim lr&, i&, lookupRng As Rangecell As Rangecount&, f
    If Evaluate("=ISREF(Result!A1)"Then Sheets("Result").Delete
    Sheets
    ("Rawdata").Copy after:=Sheets("Rawdata")
    ActiveSheet.Name "Result"
    Columns(3).Insert
    lr 
    Cells(Rows.count"A").End(xlUp).Row
    For Each cell In Range("B2:B" lr)
        
    count WorksheetFunction.CountIf(Range("B2"cell), cell)
        
    cell.Offset(, 1).Value count
        Set lookupRng 
    Sheets(cell.Offset(, 10).Value).Columns(IIf(cell.Offset(, 18).Value "Individual"26))
        
    Set f lookupRng.Find(cell.Offset(, 8).Value)
        If 
    Not f Is Nothing Then cell.Offset(, 42).Value f.Offset(, 1).Value
    Next
    End Sub 
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-24-2023
    Location
    sydney
    MS-Off Ver
    2019
    Posts
    39

    Re: Need VBA to find Demerits code from different code segment

    Thank you alot boss for valuable time spend on me again, great piece of code, Legend

  6. #6
    Registered User
    Join Date
    02-24-2023
    Location
    sydney
    MS-Off Ver
    2019
    Posts
    39

    Re: Need VBA to find Demerits code from different code segment

    Solved!! thanks alot of kudos to u

+ 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] Need VBA code to popup Email Depends upon userform of Segment
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-08-2023, 01:40 AM
  2. Need vba code to find acc keys from bulk segment data
    By henrybrothers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2023, 07:40 PM
  3. [SOLVED] Find the code inside the text and return the code in another column
    By rickyilas in forum Excel General
    Replies: 4
    Last Post: 06-27-2022, 03:14 AM
  4. VBA code for Lookup Code-used to find last non zero value in search column
    By DhillonJ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2019, 04:11 AM
  5. [SOLVED] Need vba code to get row lines from master through A and C col key code segment wise
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2016, 12:29 AM
  6. I need to add a verify segment to this code
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2016, 09:53 AM
  7. VBA code to find the code in both Payer and receiver and do concontate
    By julielara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2016, 01:59 AM

Tags for this Thread

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