+ Reply to Thread
Results 1 to 8 of 8

Mark cells based on a requirement

  1. #1
    Registered User
    Join Date
    04-18-2022
    Location
    Spain
    MS-Off Ver
    2020
    Posts
    6

    Mark cells based on a requirement

    Hello everybody

    Im having some work with excel that is very time consuming, and I was wonder if there is possible to do it faster with macros. I have try with my little knoledge but I cant find the solution. So, lets explain.

    I have 2 columns that represent every posible case of the combinatios from 1 to 5, that is:

    1 2
    1 3
    1 4
    1 5
    2 3
    2 4
    2 5
    3 4
    3 5
    4 5

    On other sheet I have the cases a participant has made, in 2 columns again, that mark the combination that appeared, for example:

    1 2
    1 3
    3 4
    4 5

    What I am trying to do is, on the first sheet where I have all the posible combinations, it is possible to mark with 1 and 0 on the next column the cases that I have in the other sheet?

    The final product would be something like this:

    1 2 1
    1 3 1
    1 4 0
    1 5 0
    2 3 0
    2 4 0
    2 5 0
    3 4 1
    3 5 0
    4 5 1


    Maybe I am overcomplicating it trying to do macros but I need help on this if you know any easier way.

    Thank you!

  2. #2
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Mark cells based on a requirement

    1 to 5, 1 to 5

    has 25 permutations, 5x5

    Do you want to represent what you're showing instead?

  3. #3
    Registered User
    Join Date
    04-18-2022
    Location
    Spain
    MS-Off Ver
    2020
    Posts
    6

    Re: Mark cells based on a requirement

    Yes, because I dont need the repeated ones, thank you!

  4. #4
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Mark cells based on a requirement

    Can you post an example workbook (see yellow ribbon at the top)... I want to write you a code that works for what you already have. I can write you a code in 10 minutes

  5. #5
    Registered User
    Join Date
    04-18-2022
    Location
    Spain
    MS-Off Ver
    2020
    Posts
    6

    Re: Mark cells based on a requirement

    Sure thing, I think I have done it right!

    What I have is the data on the 2 first sheets, and what I need is what I wrote on the final example.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Mark cells based on a requirement

    So what you have going on is totally possible to do in VBA and I will write you a code... However, I'd like to know if we can combine the two numbers into one cell.... so instead of Cell:1 Cell:2, it would be Cell:12, Cell:13, 14, 15

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to the attachment an Excel basics VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
          Const 
    "¤""&""" """&"
            
    Dim WC%, R&, V
        With 
    [Sheet1!A1].CurrentRegion.Columns
          ReDim W
    (.Count 2)
                
    1
            
    For 1 To UBound(W)
                
    W(R) = .Parent.Evaluate(.Item(C).Address & .Item(1).Address)
                
    2
            Next
        End With
        With 
    [Sheet2!A1].CurrentRegion.Columns
            
    If .Count 2 Then .Item(3).Resize(, .Count 2).ClearContents
            ReDim V
    (1 To .Rows.Count1 To UBound(W))
            
    W(0) = .Parent.Evaluate(.Item(1).Address & .Item(2).Address)
        For 
    1 To UBound(W)
            
    V(1C) = Split(W(C)(11), D)(0)
            
    W(C) = Application.Match(W(0), W(C), 0)
        For 
    2 To .Rows.Count
            V
    (RC) = -IsNumeric(W(C)(R1))
        
    Next RC
           
    .Item(3).Resize(, UBound(W)).Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  8. #8
    Registered User
    Join Date
    04-18-2022
    Location
    Spain
    MS-Off Ver
    2020
    Posts
    6

    Re: Mark cells based on a requirement

    Quote Originally Posted by carlmon View Post
    So what you have going on is totally possible to do in VBA and I will write you a code... However, I'd like to know if we can combine the two numbers into one cell.... so instead of Cell:1 Cell:2, it would be Cell:12, Cell:13, 14, 15
    If it would be easier, I can decombine it later, but I preffer the 2 columns system because Ill later use SPSS and that program need the 2 columns notation

    Quote Originally Posted by Marc L View Post

    According to the attachment an Excel basics VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
          Const 
    "¤""&""" """&"
            
    Dim WC%, R&, V
        With 
    [Sheet1!A1].CurrentRegion.Columns
          ReDim W
    (.Count 2)
                
    1
            
    For 1 To UBound(W)
                
    W(R) = .Parent.Evaluate(.Item(C).Address & .Item(1).Address)
                
    2
            Next
        End With
        With 
    [Sheet2!A1].CurrentRegion.Columns
            
    If .Count 2 Then .Item(3).Resize(, .Count 2).ClearContents
            ReDim V
    (1 To .Rows.Count1 To UBound(W))
            
    W(0) = .Parent.Evaluate(.Item(1).Address & .Item(2).Address)
        For 
    1 To UBound(W)
            
    V(1C) = Split(W(C)(11), D)(0)
            
    W(C) = Application.Match(W(0), W(C), 0)
        For 
    2 To .Rows.Count
            V
    (RC) = -IsNumeric(W(C)(R1))
        
    Next RC
           
    .Item(3).Resize(, UBound(W)).Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Oh! That solves it! Very thankful!!

+ 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] mark color for not matched items for adjacent cells based on another adjacent cells
    By tubrak in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-14-2022, 08:02 AM
  2. [SOLVED] search data based on column by inputbox user and mark the cells in the same row
    By Mussa-A in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-07-2021, 11:29 AM
  3. [SOLVED] Call macro and execute several times based on the requirement
    By jalolbek85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2021, 05:03 AM
  4. Requirement details should be segregated based on No. of Recruiters
    By ajaypal.sp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2016, 06:48 AM
  5. How to mark cells based on date in other cell using conditional formatting
    By mharsvik in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-01-2012, 12:33 PM
  6. How to mark cells based negative value or on calculation
    By klmaric in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2011, 07:15 PM
  7. [SOLVED] collecting data based on dates requirement
    By Christa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2005, 04:15 PM

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