#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default VB problem

Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
.... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
.... and the result of a formula included in equivalent cell in column D is
not an error;
.... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
.... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default VB problem

Feelu,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

"FiluDlidu" wrote in message
...
Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
... and the result of a formula included in equivalent cell in column D is
not an error;
... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default VB problem

Ooops, forgot one condition (that A is currently empty...)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Feelu,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

"FiluDlidu" wrote in message
...
Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
... and the result of a formula included in equivalent cell in column D is
not an error;
... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default VB problem

Hi Bernie,

I'm not sure why, but it worked once, then systematically failed since that
first success.\

Thanks a lot for your help anyway,

Feelu

"Bernie Deitrick" wrote:

Ooops, forgot one condition (that A is currently empty...)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Feelu,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

"FiluDlidu" wrote in message
...
Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
... and the result of a formula included in equivalent cell in column D is
not an error;
... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default VB problem


It's cause I'm a dunce.... the second instance of

Application.EnableEvents = False

should have been

Application.EnableEvents = True


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = True
End If
End Sub


--
HTH,
Bernie
MS Excel MVP


"FiluDlidu" wrote in message
...
Hi Bernie,

I'm not sure why, but it worked once, then systematically failed since that
first success.\

Thanks a lot for your help anyway,

Feelu

"Bernie Deitrick" wrote:

Ooops, forgot one condition (that A is currently empty...)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Feelu,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

"FiluDlidu" wrote in message
...
Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
... and the result of a formula included in equivalent cell in column D is
not an error;
... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu









  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default VB problem

I'm not too sure about what a dunce is (my first language is not English),
but it doesn't sound too good and I think you should be more respectful than
that to yourself, for you've been immensely helpful to me.

Your correction worked!

Thanks a lot again.

"Bernie Deitrick" wrote:


It's cause I'm a dunce.... the second instance of

Application.EnableEvents = False

should have been

Application.EnableEvents = True


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = True
End If
End Sub


--
HTH,
Bernie
MS Excel MVP


"FiluDlidu" wrote in message
...
Hi Bernie,

I'm not sure why, but it worked once, then systematically failed since that
first success.\

Thanks a lot for your help anyway,

Feelu

"Bernie Deitrick" wrote:

Ooops, forgot one condition (that A is currently empty...)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Cells(Target.Row, 1).Value = "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Feelu,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
If Cells(Target.Row, 2).Value < "" And _
Cells(Target.Row, 3).Value < "" And _
Not IsError(Cells(Target.Row, 4).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 1).Value = Cells(Target.Row, 4).Value
Application.EnableEvents = False
End If
End Sub

"FiluDlidu" wrote in message
...
Hi all,

I'm looking for a code that would do the following:

- When I press whichever data entry validation key combination(((("Enter",
"Ctrl+Enter", "Shift+Enter", "Tab" or "Shift+Tab")))) following data entry
into a cell from either B or C columns, then if...
... the cell-with-content count (COUNTA) for the same row of these two
columns (B & C) is equal to 2;
... and the result of a formula included in equivalent cell in column D is
not an error;
... and the cell of the same row in column A is empty.
- Then copy the value of cell D into cell A of the same row...
... and go to the cell where the elected keystroke would have gotten me by
default.
- If the conditions were not to be met, then just do whatever is the default
(exit sub, I guess...)

Is this too much asking? I hope not and wish to thank in advance anyone who
will put any amount of thinking, even fruitless, into this problem,

Feelu








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
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


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