Anyone good with Excel?

Anything else. Post a funny site or tell us about yourself. Discuss current events or whatever else you want. Post off topic threads here.
Post Reply
User avatar
Puma60
Advanced Member
Posts: 2241
Joined: Sat Apr 28, 2007 7:46 pm
Quick Reply: Yes
Location: The parents basement

Anyone good with Excel?

Post by Puma60 »

I have this database but I want the dates that have expired over 1 year to be automatically highlighted in red. I know it can be done because I remember someone showing me a year or so ago, anyone have any idea how to do it, or what function to use? Here's come visual aid ^^

Image

Ta very much!
Image

Retired from SRO

User avatar
NuclearSilo
Forum God
Posts: 8834
Joined: Mon Aug 21, 2006 12:00 pm
Quick Reply: Yes
Location: Age of Wushu

Re: Anyone good with Excel?

Post by NuclearSilo »

You have to learn VBA to do it:
- read the content of a cell
- analyse the date from the string
- compare
- highlight the cell
Playing Age of Wushu, dota IMBA

User avatar
CeLL
Senior Member
Posts: 4441
Joined: Tue Nov 18, 2008 4:26 am
Quick Reply: Yes
Location: SHEEKA JOOM BA BOOM BAH!! BAM! BAM BAM BAM BAM BAM!!!!!!!!!!!!

Re: Anyone good with Excel?

Post by CeLL »

NuclearSilo wrote:You have to learn VBA to do it:
- read the content of a CeLL
- analyse the date from the string
- compare
- highlight the CeLL

you just cant stop talkin about me can you silo?
Image
^^Thanks Thomas42

User avatar
Guardia
Frequent Member
Posts: 1187
Joined: Mon Dec 11, 2006 8:25 pm
Quick Reply: Yes
Location: Azteca

Re: Anyone good with Excel?

Post by Guardia »

I cant find a way to do this without using VB. If u know VB codings, try these.

Have 1 cell on each "Last Paid" column to calculate the date differences between the date on the column and the current date. U can hide that column later.

The function on cell T8
=DAYS360(S8,TODAY())

The function on cell T9
=DAYS360(S9,TODAY())

The function on cell T10
=DAYS360(S10,TODAY())


and so on. Make sure the format for the new column is set to "number".
After that, create a command button under ur table to act as a refresh button.

The coding for the refresh button should be like this :-

Code: Select all

Private Sub CommandButton1_Click()
   
    If Range("T8").Value > 365 Then
        With Range("S8").Font
            .Color = -16776961
            .Bold = True
        End With
    Else
        With Range("S8").Font
            .ColorIndex = xlAutomatic
            .Bold = False
        End With
    End If
   
    If Range("T9").Value > 365 Then
        With Range("S9").Font
            .Color = -16776961
            .Bold = True
        End With
    Else
        With Range("S9").Font
            .ColorIndex = xlAutomatic
            .Bold = False
        End With
    End If
   
    If Range("T10").Value > 365 Then
        With Range("S10").Font
            .Color = -16776961
            .Bold = True
        End With
    Else
        With Range("S10").Font
            .ColorIndex = xlAutomatic
            .Bold = False
        End With
    End If

End Sub


I believe the coding can be more simple, but I'm too lazy to think of other ways. Maybe these steps can give u the idea on how to do it. Hope it helps.
Image
(Retired) - FTW - Avalon - Azteca - 6X - Battle Bard
(Retired) - Guardia - Avalon - Venus - 9X - Battle Bard / Wizz
[Guide] Bards Explained

User avatar
NuclearSilo
Forum God
Posts: 8834
Joined: Mon Aug 21, 2006 12:00 pm
Quick Reply: Yes
Location: Age of Wushu

Re: Anyone good with Excel?

Post by NuclearSilo »

CeLL wrote:
NuclearSilo wrote:You have to learn VBA to do it:
- read the content of a CeLL
- analyse the date from the string
- compare
- highlight the CeLL

you just cant stop talkin about me can you silo?

I can't. You are too famous :(


@OP: Here is the macro you need to create
- Open Visual Basic Editor (Alt+F11)
- Insert a module
- Insert the following code into the module then save

Code: Select all

Sub HighlightExpired()
    Rng = Selection.Rows.Count
    Dim value As Date
    Dim str As String
   
    Selection.NumberFormat = "dd/mm/yyyy"
   
    For i = 1 To Rng
        str = ActiveCell.Cells(i)
        If str <> "" Then
            value = str
            If DateDiff("d", value, Date) > 365 Then    'if > 365 day
                '1=black, 2=white, 3=red, 4=green, 5=blue, 6=yellow
                ActiveCell.Cells(i).Interior.ColorIndex = 3
            End If
        End If
    Next i
End Sub


How to run?
- Select a range of cell you want to check
- Run the macro (Alt+F8)
- Choose HighlightExpired then run it

Image

PS: this is made under Excel 2003, the hotkey like alt+F11,Alt+F8 could do different thing as mentioned on different version of Excel
Playing Age of Wushu, dota IMBA

User avatar
Puma60
Advanced Member
Posts: 2241
Joined: Sat Apr 28, 2007 7:46 pm
Quick Reply: Yes
Location: The parents basement

Re: Anyone good with Excel?

Post by Puma60 »

Thanks to Silo for spending over an hour helping me :love:
Image

Retired from SRO

User avatar
NuclearSilo
Forum God
Posts: 8834
Joined: Mon Aug 21, 2006 12:00 pm
Quick Reply: Yes
Location: Age of Wushu

Re: Anyone good with Excel?

Post by NuclearSilo »

Np. :)
Try to find the ID/name of that combo box. We'll see it together tomorrow if you still didn't find it
Playing Age of Wushu, dota IMBA

User avatar
Pepsico
Common Member
Posts: 104
Joined: Mon Jan 25, 2010 9:04 am
Quick Reply: Yes
Location: Rome

Re: Anyone good with Excel?

Post by Pepsico »

Your school is weird :P Giving you assignments you cant do, should tell them to teach you the stuff before they give you homework about it ^^
Playing on Rome server.
100 Pure str bower. Pacheon. Fire. Light.
Playing on Divine SRO Private server
Logitech 120 Glavier
Angelica 120 Bicheon nuker
Sidewinder 120 Pure nuker
Master 120 Bower
Image
Image

Post Reply

Return to “Off Topic Lounge”