I want to Thank you in advance for your vast knowledge and advice which has helped me out beyond belief.
Programming is not me because I don't understand all of it but can understand the basic...sort of. I was in need of coding that changed certain cells color and I was very happy with the code that was provided by davegugg. I took his code and added another sheet (MILES) and changed the color. Everything seems to be working just runs for alittle longer than I expected. This spreadsheet will be on a network which can be slow to the field so I'm just checking to see if there is a way to speed up the code? If not then I will run with it as it is.
the DR, FH,CL, MT tabs will never be more 3,000 rows
The LOA and Miles tabs will never have more than 300 rows
Private Sub Workbook_Open()
Dim i As Integer
Dim j As Integer
Dim lngLR As Long
Dim lngNumber As Long
Dim c As Object
Dim arrWS(4) As String 'Create an array with the sheet names to loop through
arrWS(0) = "DR"
arrWS(1) = "FH"
arrWS(2) = "CL"
arrWS(3) = "MT"
'Using an array of sheet names will help the code to not be dependent upon the order of the sheets, 'and will make it easy to add more sheets in the future, if necessary.
For i = 0 To 3
lngLR = Sheets(arrWS(i)).Cells(Rows.Count, 1).End(xlUp).Row
For j = 2 To lngLR
lngNumber = Sheets(arrWS(i)).Cells(j, 1).Value
For Each c In Sheets("LOA").UsedRange.Cells
If c.Value = lngNumber Then
c.Interior.ColorIndex = 16
c.Font.Bold = True
Sheets(arrWS(i)).Cells(j, 1).Interior.ColorIndex = 16
Sheets(arrWS(i)).Cells(j, 1).Font.Bold = True
End If
Next c
Next j
Next i
"This is the section I added but I really only need it to look through the DR tab"
For i = 0 To 3
lngLR = Sheets(arrWS(i)).Cells(Rows.Count, 1).End(xlUp).Row
For j = 2 To lngLR
lngNumber = Sheets(arrWS(i)).Cells(j, 1).Value
For Each c In Sheets("MILES").UsedRange.Cells
If c.Value = lngNumber Then
c.Interior.ColorIndex = 40
c.Font.Bold = True
Sheets(arrWS(i)).Cells(j, 1).Interior.ColorIndex = 40
Sheets(arrWS(i)).Cells(j, 1).Font.Bold = True
End If
Next c
Next j
Next i
End Sub
Thanks
Michelle
Bookmarks