Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default Accept on condition only !

Hi,
I want to use Input Box's to enter data to cells C2:C, D2;D and E2:E row by
row for Sheet1. But I need to check if the info I input for cells (C2:C AND
D2:D both) does not exist in the region of B4:AY14 on Sheet2 (where the rows
represents info similar to C2:C and columns represent info similar to D2:D
on Sheet1) !. Hope I summerized it correctly.
How can I do it?. (With and without VBA)
TIA
J_J


  #2   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default conditional input only !-corrected

Hi,

Sorry about my mistakes in the previous post. I think I wasn't very
sucessful giving a

clear view of my problem. Here is a much clearer description of my excel
problem...

-----------

I want to use Input Box's to enter data to columns C2:C, D2;D and E2:E row
by
row on Sheet1 (where the info on column C, D and E will hold the data for
"period",

"activity" and "trainer" respectively).

On Sheet2's A4:A column, I have a list of all possible "tariner" values of
Sheet1.
On Sheet2's B3:AY3 range, I have a list of all possible "period" values of
Sheet1.

Lastly on range B4:AY21 of Sheet2, I use VLOOKUP to display the "activity"
cell info for

the matching "period" and "trainer" values retrieved from Sheet1.

So far so good. No problems. I can manage that.

But before actually accepting and "writing" the data into the columns of
C2:C, D2:D and

E2:E as rows of new elements on Sheet1, I need to make sure that the info
I'll input on

Sheet1 for each row of cells ("period" & "activity" & "trainer" values)
there doesn't exist

another row with the same data trio.

Hope I summerized it correctly this time.

How can I do it?. (With and without VBA)
TIA

J_J


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accept on condition only !


In the module for sheet1, you can write the following code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 And Target.Column <= 5 Then ' 3 to 5 stand for
to E columns

For i = 1 To Target.Row - 1

If (Cells(i, 3) = Cells(Target.Row, 3)) And (Cells(i, 4)
Cells(Target.Row, 4)) And (Cells(i, 5) = Cells(Target.Row, 5)) Then
MsgBox "Duplicate record"
End If

Next

End If

End Sub


- Manges

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=27585

  #4   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default Accept on condition only !

Thanks mangesh_yadav,
I'll try this and get back to this thread for comment.
J_J

"mangesh_yadav" wrote in
message ...

In the module for sheet1, you can write the following code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 And Target.Column <= 5 Then ' 3 to 5 stand for C
to E columns

For i = 1 To Target.Row - 1

If (Cells(i, 3) = Cells(Target.Row, 3)) And (Cells(i, 4) =
Cells(Target.Row, 4)) And (Cells(i, 5) = Cells(Target.Row, 5)) Then
MsgBox "Duplicate record"
End If

Next

End If

End Sub


- Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile:

http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=275852



  #5   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default Accept on condition only !

Hi mangesh,

Thank you so much for your code. It works perfectly OK.
I need just a little bit further then this to make it even more effective.

Your code reminds the user that a "duplicate recored" has been entered.
But I think that it will be even better if the code "removes" the entered
duplicate row as well when we click pass "OK" the message box.

A second (and much more needed) improvement to your code may be this:

Can we add another "If" statement to your code so that when we input the
"period" & "activity" & "trainer" values it will also check columns 3, 4, 5
and if it finds that there is a PARTLY match (only the "period" & "activity"
data matches but "trainer" data differs) then the program will warn the user
by displaying a message box with the message "The " & activity & " lesson on
" & "period" & "is beeing used by " & <The found unmatched trainer name ?

"Should I remove the old record and put this new data line to the sheet
(Y/N)?"
And if we enter "Y" OR "y" it will do so, but if we enter anything else it
will keep the old record and delete the lastly entered partly matching row?

Hope I have not asked too much

Regards
Sincerely
J_J

"J_J" wrote in message
...
Thanks mangesh_yadav,
I'll try this and get back to this thread for comment.
J_J

"mangesh_yadav" wrote in
message ...

In the module for sheet1, you can write the following code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 And Target.Column <= 5 Then ' 3 to 5 stand for C
to E columns

For i = 1 To Target.Row - 1

If (Cells(i, 3) = Cells(Target.Row, 3)) And (Cells(i, 4) =
Cells(Target.Row, 4)) And (Cells(i, 5) = Cells(Target.Row, 5)) Then
MsgBox "Duplicate record"
End If

Next

End If

End Sub


- Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile:

http://www.excelforum.com/member.php...o&userid=10470
View this thread:

http://www.excelforum.com/showthread...hreadid=275852







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
I want a cell should 2 accept only =0 or <=30 or Y or N Brijesh Poojary New Users to Excel 1 April 6th 10 06:45 AM
Accept or Reject a value crabflinger Excel Worksheet Functions 1 April 3rd 09 05:46 PM
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
Track/Accept Changes WhOkNoWs Excel Worksheet Functions 0 August 22nd 07 02:26 PM
license box accept sherrysue11 Excel Discussion (Misc queries) 0 July 20th 06 02:42 PM


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