Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Updating Excel Code

HI can some please assist with this issue on updating Excel I have written
some code in Excel thet when you put in a certain letter in a cell it should
turn the cell a different colour.

Now this does not happen until you go in to view code and click run, WHY?

I have set calculations to automatic in options but I still have to go into
view code

Any Ideas many thanks





--
N/A
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Updating Excel Code

Hi Joel,

Try posting your code.


---
Regards,
Norman



"Joel" wrote in message
...
HI can some please assist with this issue on updating Excel I have written
some code in Excel thet when you put in a certain letter in a cell it
should
turn the cell a different colour.

Now this does not happen until you go in to view code and click run, WHY?

I have set calculations to automatic in options but I still have to go
into
view code

Any Ideas many thanks





--
N/A



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Updating Excel Code

Hi Norman this be the code

Private Sub Worksheet_Calculate()

Dim oCell As Range
For Each oCell In Range("V3:GU36")
Select Case oCell.Value
Case Is < 1
oCell.Interior.ColorIndex = xlNone

' This is for Holidays UPPERCASE
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "H"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Day Holidays UPPERCASE
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "H/2"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Holidays lowercase
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "h"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Day Holidays lowercase
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "h/2"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' End of the Holiday Section

'Start of Bank Holidays

' This is for Half Days Bank Holiday lowercase
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "bh/2"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Days Bank Holiday UPPERCASE
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "BH/2"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Bank Holiday lowercase
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "bh"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Bank Holiday UPPERCASE
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "BH"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

End Select
Next oCell
End Sub
--
N/A


"Norman Jones" wrote:

Hi Joel,

Try posting your code.


---
Regards,
Norman



"Joel" wrote in message
...
HI can some please assist with this issue on updating Excel I have written
some code in Excel thet when you put in a certain letter in a cell it
should
turn the cell a different colour.

Now this does not happen until you go in to view code and click run, WHY?

I have set calculations to automatic in options but I still have to go
into
view code

Any Ideas many thanks





--
N/A




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Updating Excel Code

The Calculate event wouldn't necessarily trigger merely by changing a value
of a cell unless referenced by some other formula. But if/when it does work
I magine it would take a long time to run with all those cells to loop
through.

Try the Change event, eg

rename Private Sub Worksheet_Calculate() to
Private Sub myFormat(oCell As Range)

comment out Dim oCell as range and the For...Next pair

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cel As Range

On Error GoTo errExit
Set rng = Intersect(Range(("V3:GU36"),Target)
If Not rng Is Nothing Then
For Each cel In rng
myFormat cel
Next
End If

errExit:
End Sub

You might also want to include the following in the Select case -

Case Else
oCell.Interior.ColorIndex = xlNone
oCell.Font.ColorIndex = xlAutomatic
oCell.Font.Bold = False

Bob's link will probably serve you better.

Regards,
Peter T


"Joel" wrote in message
...
Hi Norman this be the code

Private Sub Worksheet_Calculate()

Dim oCell As Range
For Each oCell In Range("V3:GU36")
Select Case oCell.Value
Case Is < 1
oCell.Interior.ColorIndex = xlNone

' This is for Holidays UPPERCASE
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "H"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Day Holidays UPPERCASE
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "H/2"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Holidays lowercase
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "h"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Day Holidays lowercase
' The Colour for this Cell is Green
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "h/2"
oCell.Interior.ColorIndex = 10
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' End of the Holiday Section

'Start of Bank Holidays

' This is for Half Days Bank Holiday lowercase
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "bh/2"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Half Days Bank Holiday UPPERCASE
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "BH/2"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Bank Holiday lowercase
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "bh"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

' This is for Bank Holiday UPPERCASE
' The Colour for this Cell is Pink
' The Color of the Font is White
' The font in the cell is emboldened

Case Is = "BH"
oCell.Interior.ColorIndex = 7
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True

End Select
Next oCell
End Sub
--
N/A


"Norman Jones" wrote:

Hi Joel,

Try posting your code.


---
Regards,
Norman



"Joel" wrote in message
...
HI can some please assist with this issue on updating Excel I have

written
some code in Excel thet when you put in a certain letter in a cell it
should
turn the cell a different colour.

Now this does not happen until you go in to view code and click run,

WHY?

I have set calculations to automatic in options but I still have to go
into
view code

Any Ideas many thanks





--
N/A






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Updating Excel Code

Sounds as though you have not put it in the correct module.

Have you tried conditions formatting,
http://www.contextures.com/xlCondFormat01.html

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Joel" wrote in message
...
HI can some please assist with this issue on updating Excel I have written
some code in Excel thet when you put in a certain letter in a cell it

should
turn the cell a different colour.

Now this does not happen until you go in to view code and click run, WHY?

I have set calculations to automatic in options but I still have to go

into
view code

Any Ideas many thanks





--
N/A





Reply
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
Updating Source Code in Charts University Charts and Charting in Excel 0 September 19th 06 08:12 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM
Updating VB Code Adam Excel Programming 4 April 25th 05 03:43 PM
When updating a worksheet, how do I create a link updating the sa. Phlashh Excel Worksheet Functions 9 January 27th 05 06:05 PM
Updating form labels from code in a module news.verizon.net[_2_] Excel Programming 2 October 29th 03 04:03 AM


All times are GMT +1. The time now is 11:14 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"