|
-
Sep 11th, 2013, 08:08 AM
#15
Junior Member
Re: [RESOLVED] (VBA) Color row if cell contains a number
Hello Bryce,
Don't now how to start a ne thread or if I need to.
This is how the code is now and need to ad on more thing. As an addition in this script I need borders on the rows wich are active. In this case it needs to start in the second row and until the last row wich contains data. I've had a look around but this is out of my league. Can you help? When you look at the pic below in needs to look like this..This is how the script is now:
Sub Bestio_Daily()
' runs macro for Bestio daily report
Application.ScreenUpdating = False
Dim i As Long
Dim lrK As Long 'last row with a filled cell in column K
Dim lrM As Long 'last row with a filled cell in column M
Dim lr As Long 'max of lrK and lrM
Dim ws As Worksheet
Set ws = ActiveSheet
lrK = Range("k" & Rows.Count).End(xlUp).Row
lrM = Range("m" & Rows.Count).End(xlUp).Row
lr = Application.WorksheetFunction.Max(lrK, lrM)
For i = 2 To lr 'my data starts in row 1, otherwise change this
If IsDate(ws.Range("k" & i).Value) Then
If IsDate(ws.Range("m" & i).Value) Then
'both K and M have a date value, so BLUE
ws.Range("a" & i).EntireRow.Interior.ColorIndex = 50
Else
'only K is date
ws.Range("a" & i).EntireRow.Interior.Color = RGB(192, 192, 192)
End If
End If
Next i
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.RowHeight = 19.5
Columns("A:A").ColumnWidth = 19.57
Range("A1").Select
ActiveCell.FormulaR1C1 = "Bestio Daily Report for:"
Range("B1").Select
Columns("A:A").ColumnWidth = 23
Range("B1:C1").Select
ActiveCell.Value = Date
Range("B1:C1").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range("B1:C1").Select
ActiveCell.Value = Date
Range("A1:C1").Select
Selection.Font.Bold = True
End Sub 
Hope you could help?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|