Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Column value

I'm using Excel 2003

Hi,

What I'm trying to achieve is that when I change a cell in column A, let's
say A5 (but the code should work for any cell in column A), into a certain
pre-set value. e.g. "XX", "Y" and "BBB" should trigger the code, but any
other input should not trigger the code.

When I enter one of those pre-set values, the cell of the same row in column
H (so H5 in this case) should equal the entries that I'm going to enter in to
column F (F5 in this case)

When I remove these pre-set values entered in column A, the entire process
should be undone.

Thanks in advance,

Paul.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Column value

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If .Value = "XX" Or .Value = "Y" Or .Value = "BBB" Then

.Offset(0, 7).FormulaR1C1 = "=RC[-2]"
Else

.Offset(0, 7).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul Tikken" wrote in message
...
I'm using Excel 2003

Hi,

What I'm trying to achieve is that when I change a cell in column A, let's
say A5 (but the code should work for any cell in column A), into a certain
pre-set value. e.g. "XX", "Y" and "BBB" should trigger the code, but any
other input should not trigger the code.

When I enter one of those pre-set values, the cell of the same row in
column
H (so H5 in this case) should equal the entries that I'm going to enter in
to
column F (F5 in this case)

When I remove these pre-set values entered in column A, the entire process
should be undone.

Thanks in advance,

Paul.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Column value

Hi Paul

Put this code in the code sheet for the desired sheet and test it. Note that
this macro is case sensitive, but it can be changed!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isec As Range
Set isec = Intersect(Columns("A"), Target)
If Not isec Is Nothing Then
If Target = "" Then
Target.Offset(0, 7) = ""
Else
Select Case Target.Value
Case Is = "XX"
Target.Offset(0, 7).Formula = "=F" & Target.Row
Case Is = "Y"
Target.Offset(0, 7).Formula = "=F" & Target.Row
Case Is = "BBB"
Target.Offset(0, 7).Formula = "=F" & Target.Row
End Select
End If
End If
End Sub

Regards,

Per

"Paul Tikken" skrev i en meddelelse
...
I'm using Excel 2003

Hi,

What I'm trying to achieve is that when I change a cell in column A, let's
say A5 (but the code should work for any cell in column A), into a certain
pre-set value. e.g. "XX", "Y" and "BBB" should trigger the code, but any
other input should not trigger the code.

When I enter one of those pre-set values, the cell of the same row in
column
H (so H5 in this case) should equal the entries that I'm going to enter in
to
column F (F5 in this case)

When I remove these pre-set values entered in column A, the entire process
should be undone.

Thanks in advance,

Paul.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Column value

Per,

It's not working, no response at all.

Any ideas?

Paul

"Per Jessen" wrote:

Hi Paul

Put this code in the code sheet for the desired sheet and test it. Note that
this macro is case sensitive, but it can be changed!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isec As Range
Set isec = Intersect(Columns("A"), Target)
If Not isec Is Nothing Then
If Target = "" Then
Target.Offset(0, 7) = ""
Else
Select Case Target.Value
Case Is = "XX"
Target.Offset(0, 7).Formula = "=F" & Target.Row
Case Is = "Y"
Target.Offset(0, 7).Formula = "=F" & Target.Row
Case Is = "BBB"
Target.Offset(0, 7).Formula = "=F" & Target.Row
End Select
End If
End If
End Sub

Regards,

Per

"Paul Tikken" skrev i en meddelelse
...
I'm using Excel 2003

Hi,

What I'm trying to achieve is that when I change a cell in column A, let's
say A5 (but the code should work for any cell in column A), into a certain
pre-set value. e.g. "XX", "Y" and "BBB" should trigger the code, but any
other input should not trigger the code.

When I enter one of those pre-set values, the cell of the same row in
column
H (so H5 in this case) should equal the entries that I'm going to enter in
to
column F (F5 in this case)

When I remove these pre-set values entered in column A, the entire process
should be undone.

Thanks in advance,

Paul.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Column value

Bob,

It's not working, no response at all

Any ideas?

Paul

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If .Value = "XX" Or .Value = "Y" Or .Value = "BBB" Then

.Offset(0, 7).FormulaR1C1 = "=RC[-2]"
Else

.Offset(0, 7).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul Tikken" wrote in message
...
I'm using Excel 2003

Hi,

What I'm trying to achieve is that when I change a cell in column A, let's
say A5 (but the code should work for any cell in column A), into a certain
pre-set value. e.g. "XX", "Y" and "BBB" should trigger the code, but any
other input should not trigger the code.

When I enter one of those pre-set values, the cell of the same row in
column
H (so H5 in this case) should equal the entries that I'm going to enter in
to
column F (F5 in this case)

When I remove these pre-set values entered in column A, the entire process
should be undone.

Thanks in advance,

Paul.




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
Referencing date column A & time column B to get info from column TVGuy29 Excel Discussion (Misc queries) 1 January 24th 08 09:50 PM
Search for a column based on the column header and then past data from it to another column in another workbook minkokiss Excel Programming 2 April 5th 07 01:12 AM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Programming 2 December 30th 06 06:23 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
How can i have all alike product codes in column A be matched with like cities in column B and then add the totals that are in column C [email protected] Excel Programming 4 August 2nd 06 01:10 AM


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