LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Changing colour of text in cell

Even a bit more simple, and puts the Date and Time in the appropriate
cells rather than both getting a date/time.

Public Sub DataEntry()
Dim myVal As Variant
Dim dayCol As Long

'Application.Goto Reference:="InputPoint"
Selection.EntireRow.Insert
'ActiveCell.Offset(0, 0).Activate

myVal = InputBox("Enter Reading : ")
If myVal < "" Then
With ActiveCell
.Value = myVal
With .Offset(0, -1)
.Value = Time
.NumberFormat = "hh:mm"
End With
With .Offset(0, -4)
.Value = Date
.NumberFormat = "dd/mm/yy"
dayCol = Choose(WeekDay(.Value), _
10, 5, 1, 6, 21, 3, 8)
.Font.ColorIndex = dayCol
End With
With .Offset(0, -2)
.Value = Format(Date, "ddd")
.Resize(1, 3).Font.ColorIndex = dayCol
End With
End With
End If
End Sub


In article ,
"Bob Phillips" wrote:

Steve,

Just a though, you can combine some of this code and simplify it

Sub DataEntry()
Dim myVal, MyDay, DayCol

'Application.Goto Reference:="InputPoint"
Selection.EntireRow.Insert
ActiveCell.Offset(0, 0).Activate

myVal = InputBox("Enter Reading : ")
If myVal < "" Then
With ActiveCell
.Value = myVal
.Offset(0, -4) = Now
.Offset(0, -4).NumberFormat = "dd/mm/yy"
.Offset(0, -1) = Now
.Offset(0, -1).NumberFormat = "hh:mm"
With .Offset(0, -4)
Select Case Weekday(.Value)
Case 1: DayCol = 10 'green
Case 2: DayCol = 5 'blue
Case 3: DayCol = 1 'black
Case 4: DayCol = 6 'yellow
Case 5: DayCol = 21 'violet
Case 6: DayCol = 3 'red
Case 7: DayCol = 8 'turquoise
End Select

.Font.ColorIndex = DayCol
End With

.Offset(0, -2) = Format(.Offset(0, -4).Value, "ddd")
.Offset(0, -2).Resize(1, 3).Font.ColorIndex = DayCol
End With
End If
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text colour keeps changing to grey SarahM Excel Discussion (Misc queries) 0 March 12th 10 12:26 PM
Changing background colour when changing data in a cell Paoul Excel Discussion (Misc queries) 7 December 26th 08 07:25 AM
Text changing colour when bolded? Frax315 Excel Discussion (Misc queries) 3 August 21st 08 08:11 PM
Changing the colour of text packfan Excel Discussion (Misc queries) 1 November 27th 06 04:41 AM
Changing Cell Colour Audrey Ng Excel Programming 3 December 16th 03 02:58 PM


All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"