need to alter a script

mr.paul.c

New Member
Joined
Dec 10, 2010
Messages
20
After completing a previous project for the company I work for, I have since been given extra responsibilities, one of which can be done quickly and efficiently using an excel workbook.

As it happens, the purpose of this task is almost the same as my last one, so I am able to use the same codes, however I am having a bit of difficulty adapting part of it.

I've adjusted the script so that it can function, but the bit I'm struggling with are the lines of code that highlight the cells that match the criteria, at present the script highlights single cells, but what I want it to do is highlight the entire row and I'm not sure how this can be done.

The code is as follows

Code:
Dim DaysOld As Long, OrderDay As Range, lCount As Long
    
       If Not IsNumeric(TextBox1.Value) Then
        MsgBox "The ""Days Old"" value requires a number.", vbCritical, "Days Old Error."
        Exit Sub
    End If
    'the above code checks that the value entered in the textbox is a number, and is not left blank
    DaysOld = Int(TextBox1.Value)
    
    For Each OrderDay In Range("F1", Range("F" & Rows.Count).End(xlUp)) 'Looks for the last used cell in Columns A-F
    
        If IsDate(OrderDay) Then
            If OrderDay.Value < Date - DaysOld Then 'if the date a collection is booked is less than todays date minus number of days entered in the text box
                OrderDay.Interior.ColorIndex = 3 'colours the inside of the cell red
                lCount = lCount + 1 'counts the number of collections coloured by above script
            Else
                OrderDay.Interior.ColorIndex = 0 'if a cell does not meet above criteria the fill colour is not applied
            End If
        End If
    Next OrderDay
   UserForm1.Hide 'closes the user form

    If lCount = 0 Then
        MsgBox "No orders found.", vbInformation, "Error" 'pop up announcement box
    Else
        MsgBox lCount & "collections need chasing.", vbInformation, "Information" 'displayed text example "10 collections need chasing"
    End If


Also, I spotted this thread and having a similar feature in my workbook would be great, but again I have a question about that:

Whilst I can follow and sort of understand the instructions on the link in that thread, I'm not really sure how to use Worksheet_SelectionChange and tell excel that whenever I click on a cell in Column F for example, the pop up calendar would open etc.

thanks in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
where it says OrderDay.interior.colorindex = 3

try Orderday.entirerow.interior.colorindex = 3
 
Upvote 0
where it says OrderDay.interior.colorindex = 3

try Orderday.entirerow.interior.colorindex = 3


A solution so simple yet took so long to realise. I'd tried all sorts of other methods and got nowhere.

Don't suppose you could give me some insight on the calendar thing?
 
Upvote 0
I found that link in another thread, what I don't quite understand is how to get the calendar to pop up if I click in a particular range of cells - which in my case would be any cell from F2 and H2 downwards (F&H1 are both column titles)
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top