Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10
Default To format a cell pattern by VBA

I have a worksheet that records attendance with code that enters
"Present" when double clicked.

Can I have VBA code to format the pattern to a colour?

Thanks for your help,

Robin Chapple
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 221
Default To format a cell pattern by VBA

Why do you need VBA? Why don't you instead use Conditional Formatting?
Format--Conditional Formatting.
****************************
Hope it helps!
Anne Troy
www.OfficeArticles.com
****************************
"Robin Chapple" wrote in message
...
I have a worksheet that records attendance with code that enters
"Present" when double clicked.

Can I have VBA code to format the pattern to a colour?

Thanks for your help,

Robin Chapple



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,624
Default To format a cell pattern by VBA

One way:

Modify your existing code to add the color at the same time, for
instance:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
If Not Intersect(Target.Cells, Range("A2:J100")) Is Nothing Then
With Target
.Value = "Present"
.Interior.ColorIndex = 37
End With
End If
End Sub


In article ,
Robin Chapple wrote:

I have a worksheet that records attendance with code that enters
"Present" when double clicked.

Can I have VBA code to format the pattern to a colour?

Thanks for your help,

Robin Chapple

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,624
Default To format a cell pattern by VBA

Since the OP's already running an event macro to change the cell
contents, using VBA to format the cell has several advantages:

(1) Simplicity - controlling changes to the double-clicked cell in one
place rather than 2,

(2) The OP indicated that the initiating event for the color should be
the double-click, not the content (that *might* work the same, but it
wasn't stated that way), and

(3) The OP didn't indicate that the color would continue to be dependent
on the cell content, so CF might be appropriate or not - there's not
enough info to tell.


In article ,
"Anne Troy" wrote:

Why do you need VBA? Why don't you instead use Conditional Formatting?
Format--Conditional Formatting.
****************************
Hope it helps!

  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10
Default To format a cell pattern by VBA


Many thanks Anne. That worked as planned.

Robin

On Sun, 25 Mar 2007 00:56:32 -0400, "Anne Troy"
wrote:

Why do you need VBA? Why don't you instead use Conditional Formatting?
Format--Conditional Formatting.
****************************
Hope it helps!
Anne Troy
www.OfficeArticles.com
****************************
"Robin Chapple" wrote in message
.. .
I have a worksheet that records attendance with code that enters
"Present" when double clicked.

Can I have VBA code to format the pattern to a colour?

Thanks for your help,

Robin Chapple



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
cell pattern footer wsk Excel Discussion (Misc queries) 1 May 14th 06 02:21 PM
Cell pattern BBlue Excel Discussion (Misc queries) 0 March 23rd 06 08:49 PM
Cell pattern Gary''s Student Excel Discussion (Misc queries) 0 March 23rd 06 08:49 PM
countif cell pattern = Steve1154 Excel Worksheet Functions 2 February 15th 06 12:38 PM
Cell Pattern Peter M Excel Discussion (Misc queries) 2 January 11th 05 02:13 AM


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

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

About Us

"It's about Microsoft Excel"