+ Reply to Thread
Results 1 to 5 of 5

Coinvert from Yellow Range to Green Range

Hybrid View

  1. #1
    Spammer
    Join Date
    06-29-2020
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    95

    Coinvert from Yellow Range to Green Range

    All Method (Formula, VBA, ...)
    Attached Files Attached Files

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

    Re: Coinvert from Yellow Range to Green Range

    Hi
    Try
    Sub test()
        Dim a, b As Variant
        Dim i, l As Long
        l = 1
        a = Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
        ReDim b(1 To UBound(a), 1 To 3)
        For i = l To UBound(a) / 3 - 1
            If a(l, 1) <> a(l + 1, 1) Then
                b(l, 1) = a(l, 1): b(l, 2) = a(l + 1, 1): b(l, 3) = a(l + 2, 1)
                l = l + 3
            Else
                l = l + 1
                b(l, 1) = a(l, 1): b(l, 2) = a(l + 1, 1): b(l, 3) = a(l + 2, 1)
                l = l + 3
            End If
        Next
        Cells(1, 7).Resize(UBound(b, 1), UBound(b, 2)) = b
    End Sub
    Last edited by mohadin; 11-02-2020 at 03:49 AM.

  3. #3
    Spammer
    Join Date
    06-29-2020
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    95

    Re: Coinvert from Yellow Range to Green Range

    mohadin. Great.
    In another case, if there are more than 2 cells under a text box or there is only 1 number format cell, how to edit the code above?
    Thank you

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,591

    Re: Coinvert from Yellow Range to Green Range

    Simply
    Sub test()
        Dim r As Range
        For Each r In Columns(1).SpecialCells(2, 1).Areas
            r(0, 3) = r(0).Value
            r(0, 4).Resize(, r.Count).FormulaArray = "=transpose(" & r.Address & ")"
        Next
    End Sub

  5. #5
    Spammer
    Join Date
    06-29-2020
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    95

    Re: Coinvert from Yellow Range to Green Range

    jindon is very nice. Your code solved my other case, thanks

+ 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. Make Gauge graph like spedometer but Red-Yellow-Green-Yellow-Red
    By rpinxt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2020, 08:13 AM
  2. [SOLVED] Return Green, Yellow or Red based on % on a specific cell
    By rz6657 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-11-2018, 03:58 PM
  3. Replies: 5
    Last Post: 08-17-2016, 06:45 PM
  4. [SOLVED] Conditional Formatting- date with red, yellow or green
    By ldurham in forum Excel General
    Replies: 2
    Last Post: 02-03-2014, 07:38 AM
  5. conditional formating dates green, yellow and red
    By mfairhurst1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 08:21 AM
  6. Dashboard budget vs actuals (green, yellow or red)
    By ChrisNor in forum Excel General
    Replies: 8
    Last Post: 12-10-2011, 06:01 AM
  7. [SOLVED] Can I sort columns by colors, example - red, green, yellow
    By Beth in forum Excel General
    Replies: 3
    Last Post: 05-19-2006, 12:40 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