#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default VB Code..

Hi All,

I would like to create a Macro so that when a cell in column H on a
spreadsheet is edited the contents is checked and changed if it is a
certain value.

Can anybody offer any help as to how I can do this?

Q1 changed to Q1 15/05/07
Q2 changed to Q2 15/08/07
Q3 changed to Q3 15/11/07
Q4 changed to Q4 15/02/08

Many thanks,
Mark

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VB Code..

One way:

Put this in your worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell As Range
Dim rH As Range
Dim sReplace As String

Set rH = Intersect(Target.Cells, Range("H:H"))
If Not rH Is Nothing Then
For Each rCell In rH
Select Case rCell.Text
Case "Q1"
sReplace = "Q1 15/05/07"
Case "Q2"
sReplace = "Q2 15/08/07"
Case "Q3"
sReplace = "Q3 15/11/07"
Case "Q4"
sReplace = "Q4 15/02/08"
End Select
If sReplace < vbNullString Then
On Error Resume Next
Application.EnableEvents = False
rCell.Value = sReplace
Application.EnableEvents = True
On Error GoTo 0
sReplace = vbNullString
End If
Next rCell
End If
End Sub




In article .com,
"MarkHear1" wrote:

Hi All,

I would like to create a Macro so that when a cell in column H on a
spreadsheet is edited the contents is checked and changed if it is a
certain value.

Can anybody offer any help as to how I can do this?

Q1 changed to Q1 15/05/07
Q2 changed to Q2 15/08/07
Q3 changed to Q3 15/11/07
Q4 changed to Q4 15/02/08

Many thanks,
Mark

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
How to assign same code inside Option button code space ?? furbiuzzu Excel Programming 1 November 21st 06 02:36 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 06:21 PM.

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"