+ Reply to Thread
Results 1 to 1 of 1

VBA Set a status based on a condition

Hybrid View

  1. #1
    Registered User
    Join Date
    06-16-2021
    Location
    Berlin
    MS-Off Ver
    Excel
    Posts
    2

    VBA Set a status based on a condition

    Hello,

    I have a workbook with the worksheets Overview, Table_D and Table_P.


    I already have a macro which checks the numbers from Table_D and Table_P in Overview. If a number is not present, it is inserted into Overview with the associated data.

    The numbers from Overview have now to be checked cell by cell whether they appear in "Table_D" or "Table_P". If the category "D" with a number is not found in "Table_D", "closed" should be written for this row in column L, the same for P: If the category "P" with the number is not found in "Table_P", "closed" should be written for this row in column L.
    If a number from Overview is found in Table_D or Table_P, column L should remain empty. This function is to be integrated into the existing macro.

    I would be very grateful if someone can help me

    Option Explicit
    
    
    
    
    
    Sub Daten_in_Overview()
    
    Dim alleD As Variant, alleP As Variant, alleOverview As Variant
    
    Dim lastCell As Long, n As Long, x As Long
    
    Dim available As Boolean
    
    
    
    With Worksheets("Table_D")
    
        alleD = .Range("A3:J" & .Cells(.Rows.Count, "A").End(xlUp).Row).Value
    
    End With
    
    
    
    With Worksheets("Table_P")
    
        alleP = .Range("A3:J" & .Cells(.Rows.Count, "A").End(xlUp).Row).Value
    
    End With
    
    
    
    
    
    With Worksheets("Overview")
    
       
    
        leereZeile = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    
       
    
        alleOverview = .Range("B2:B" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
    
    
    
        For n = 1 To UBound(alleD, 1) - 1
    
            For x = 1 To UBound(alleOverview)
    
                If alleD(n, 1) = alleOverview(x, 1) Then   
    
                    available = True
    
                    Exit For
    
                End If
    
            Next x
    
           
    
            If vorhanden = False Then  
    
                .Range("A" & lastCell).Value = "D"
    
                .Range("L" & lastCell).Value = "new" 
    
               
    
                For x = 1 To UBound(alleD, 2)
    
                    .Cells(lastCell, x + 1) = alleD(n, x)
    
                Next x
    
               
    
              
    
               
    
                alleOverview = .Range("B2:B" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
    
                leereZeile = lastCell + 1
    
            End If
    
           
    
            available = False
    
        Next n
    
       
    
        For n = 1 To UBound(alleP, 1) - 1
    
            For x = 1 To UBound(alleOverview)
    
                If alleP(n, 1) = alleOverview(x, 1) Then    
    
                    available = True
    
                    Exit For
    
                End If
    
            Next x
    
           
    
            If available = False Then  
    
                .Range("A" & lastCell).Value = "P"
    
                .Range("L" & lastCell).Value = "new" 
    
               
    
                For x = 1 To UBound(alleD, 2)
    
                    .Cells(lastCell, x + 1) = alleP(n, x)
    
                Next x
    
               
    
                alleOverview = .Range("B2:B" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
    
                leereZeile = lastCell + 1
    
            End If
    
           
    
            available = False
    
        Next n
    
    
    
    End With
    
    End Sub
    Attached Files Attached Files

+ 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] Automatically give status to condition
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-25-2018, 09:43 AM
  2. IF Condition statement for Final Status
    By Rushendra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-02-2016, 04:50 AM
  3. Replies: 3
    Last Post: 09-11-2014, 04:32 PM
  4. [SOLVED] How to use macro to change status in column A by condition
    By Adamlearnexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2013, 02:20 AM
  5. [SOLVED] How to Set a Condition that colors a cell based on status
    By Dmarz in forum Excel General
    Replies: 4
    Last Post: 12-03-2012, 09:56 AM
  6. Replies: 4
    Last Post: 04-08-2012, 09:43 PM
  7. Help: IF Nested condition based on Date to determine Status
    By shoro in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 01-10-2012, 10:21 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