Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Pop up message needed dependend on certain conditions

In cell range C7:C14 the cells can have different values (1, 2, 3, .....)
In case there is only 1 kind of value (only value 1, or only value 2) I'd like to get a message (pop up, or in a certain cell), which says "blablabla"
I'd like to get different messages for different values, though.

For example: C7 = 1
C8 = 1
C9 = 1
Message to pop up: "Please be aware that pattern repeat to be divisible by 4"

C7 = 2
C8 = 2
C9 = 2
C10 = 2
Message to pop up: "Please be aware that pattern repeat to be divisible by 12"

For example: C7 = 1
C8 = 2
C9 = 1
No message to pop up


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Pop up message needed dependend on certain conditions

Norbert wrote:

In cell range C7:C14 the cells can have different values (1, 2, 3,
.....) In case there is only 1 kind of value (only value 1, or only
value 2) I'd like to get a message (pop up, or in a certain cell), which
says "blablabla" I'd like to get different messages for different
values, though.

For example: C7 = 1
C8 = 1
C9 = 1
Message to pop up: "Please be aware that pattern repeat to be divisible
by 4"

C7 = 2
C8 = 2
C9 = 2
C10 = 2
Message to pop up: "Please be aware that pattern repeat to be divisible
by 12"

For example: C7 = 1
C8 = 2
C9 = 1
No message to pop up


This ensures that there are at least 2 unique values in C7:C14, and at least
2 non-blank cells. If there aren't (i.e. everything's the same) then you get
a msgbox.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L0, L1, tracker As Boolean
If (Target.Column < 3) Or (Target.Row < 7) Or (Target.Row 14) Then _
Exit Sub
For L0 = 7 To 13
If Cells(L0, 3).Value < "" Then
For L1 = 8 To 14
If Cells(L1, 3).Value < "" Then
tracker = True
If Cells(L0, 3).Value < Cells(L1, 3).Value Then Exit Sub
End If
Next
End If
Next
If tracker Then MsgBox "your message here"
End Sub

--
I wonder if he thinks he's the hero or the villain?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Pop up message needed dependend on certain conditions

On Monday, 26 March 2018 17:24:59 UTC+2, Auric__ wrote:
Norbert wrote:

In cell range C7:C14 the cells can have different values (1, 2, 3,
.....) In case there is only 1 kind of value (only value 1, or only
value 2) I'd like to get a message (pop up, or in a certain cell), which
says "blablabla" I'd like to get different messages for different
values, though.

For example: C7 = 1
C8 = 1
C9 = 1
Message to pop up: "Please be aware that pattern repeat to be divisible
by 4"

C7 = 2
C8 = 2
C9 = 2
C10 = 2
Message to pop up: "Please be aware that pattern repeat to be divisible
by 12"

For example: C7 = 1
C8 = 2
C9 = 1
No message to pop up


This ensures that there are at least 2 unique values in C7:C14, and at least
2 non-blank cells. If there aren't (i.e. everything's the same) then you get
a msgbox.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L0, L1, tracker As Boolean
If (Target.Column < 3) Or (Target.Row < 7) Or (Target.Row 14) Then _
Exit Sub
For L0 = 7 To 13
If Cells(L0, 3).Value < "" Then
For L1 = 8 To 14
If Cells(L1, 3).Value < "" Then
tracker = True
If Cells(L0, 3).Value < Cells(L1, 3).Value Then Exit Sub
End If
Next
End If
Next
If tracker Then MsgBox "your message here"
End Sub

--
I wonder if he thinks he's the hero or the villain?


Hello Auric,

first of all thank you for your help! At first, I had no clue what you did and had to play with the code a little to understand. I tried to change it to do the following:
- as soon as I have made the 4th entry (into cell C10) I want the code to check
whether there is all ones, twos, threes, ......
- in case there is all ones I want the message to be: "Please ensure the pick
repeat to be divisible by 4"
- in case there is all twos, I want the message to be: "Please ensure the pick
repeat to be divisible by 12"
that is all for now! (I think I can extend it myself if I have code for above requirements)

That's how far I got:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L0, L1, tracker1 As Boolean
If (Target.Column < 3) Or (Target.Row < 7) Or (Target.Row 14) Then _
Exit Sub
For L0 = 7 To 13
If Cells(L0, 3).Value = 1 Then
For L1 = 10 To 14
If Cells(L1, 3).Value = 1 Then
tracker1 = True
If Cells(L0, 3).Value < Cells(L1, 3).Value Then Exit Sub
End If
Next
End If
Next
Dim L2, L3, tracker2 As Boolean
If (Target.Column < 3) Or (Target.Row < 7) Or (Target.Row 14) Then _
Exit Sub
For L2 = 7 To 13
If Cells(L2, 3).Value = 2 Then
For L3 = 10 To 14
If Cells(L3, 3).Value = 2 Then
tracker2 = True
If Cells(L2, 3).Value < Cells(L3, 3).Value Then Exit Sub
End If
Next
End If
Next
If tracker1 Then MsgBox "Please ensure that the pick repeat is divisible by 4 (for Reppe)"
If tracker2 Then MsgBox "Please ensure that the pick repeat is divisible by 12 (for Satin)"
End Sub

It works for when it is all ones or when it is all twos, but it also comes up
with a message, when it is mixed (ones and twos).
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Pop up message needed dependend on certain conditions

Norbert wrote:

On Monday, 26 March 2018 17:24:59 UTC+2, Auric__ wrote:
Norbert wrote:

In cell range C7:C14 the cells can have different values (1, 2, 3,
.....) In case there is only 1 kind of value (only value 1, or only
value 2) I'd like to get a message (pop up, or in a certain cell),
which says "blablabla" I'd like to get different messages for
different values, though.

For example: C7 = 1
C8 = 1
C9 = 1
Message to pop up: "Please be aware that pattern repeat to be
divisible by 4"

C7 = 2
C8 = 2
C9 = 2
C10 = 2
Message to pop up: "Please be aware that pattern repeat to be
divisible by 12"

For example: C7 = 1
C8 = 2
C9 = 1
No message to pop up


This ensures that there are at least 2 unique values in C7:C14, and at
least 2 non-blank cells. If there aren't (i.e. everything's the same)
then you get a msgbox.

[snip]
Hello Auric,

first of all thank you for your help! At first, I had no clue what you
did and had to play with the code a little to understand. I tried to
change it to do the following: - as soon as I have made the 4th entry
(into cell C10) I want the code to check
whether there is all ones, twos, threes, ......
- in case there is all ones I want the message to be: "Please ensure the
pick repeat to be divisible by 4"
- in case there is all twos, I want the message to be: "Please ensure
the pick repeat to be divisible by 12"
that is all for now! (I think I can extend it myself if I have code for
above requirements)

That's how far I got:

[snip]
It works for when it is all ones or when it is all twos, but it also
comes up with a message, when it is mixed (ones and twos).


Try this. It won't pop the msgbox up unless there are at least 4 entered
values. I've also commented everything so you can see each line's purpose.
Note that as-is, it will bitch about *any* series of identical non-blank
values, whether it's 1, 2, a, $, whatever. To avoid that, delete the Case
Else at the end.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L0, L1, checkVal, tracker As Long
'If Target (the changed range) is outside C7:C14, exit.
If (Target.Column < 3) Or (Target.Row < 7) Or (Target.Row 14) Then _
Exit Sub
'Check for blank C7 and set tracker appropriately.
'(to avoid off-by-one error).
If Range("C7").Value < "" Then tracker = 1
'For each cell in C7:C13...
For L0 = 7 To 13
'...ensure it's not blank, then...
If Cells(L0, 3).Value < "" Then
'...stuff the value into a var for later use, then...
checkVal = Cells(L0, 3).Value
'...compare against all cells below it....
For L1 = 8 To 14
'...also ensuring each one is not blank.
If Cells(L1, 3).Value < "" Then
'This is set to check for multiple non-blank cells,
'for later use.
tracker = tracker + 1
'Non-unique values; exit the sub with no further action.
If Cells(L0, 3).Value < Cells(L1, 3).Value Then Exit Sub
End If
Next
End If
Next
'If we get here, then:
'- there are multiple non-blank cells, and
'- every cell in C7:C13 has the same value.
'The value we check tracker against (3 in this example)
'might need to be adjusted to suit your needs.
If tracker 3 Then
Select Case checkVal
Case 1
MsgBox "Please ensure the pick repeat to be divisible by 4"
Case 2
MsgBox "Please ensure the pick repeat to be divisible by 12"
Case 3
MsgBox "You mentioned 'all threes'..."
Case Else
MsgBox "All identical values but not a listed option"
End Select
End If
End Sub

--
peanut butter is my spiritual guide
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Pop up message needed dependend on certain conditions

Great! I am happy with the way it works. And thank you very much for your comments in between, that helps me a lot to better understand the code.
The Case Else is helpful as well.
Best regards!
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
help needed to add values with conditions Bishkan Excel Worksheet Functions 4 December 9th 09 01:29 PM
Formula Needed : Sum on Conditions K[_2_] Excel Discussion (Misc queries) 3 January 27th 09 03:57 PM
Formula Needed : Sum on Conditions K[_2_] Excel Programming 2 January 27th 09 03:21 PM
Date Formula with 2 conditions met needed Amanda Excel Discussion (Misc queries) 7 January 8th 09 05:48 PM
Two conditions in one cell. Help needed ASAP Marty Excel Discussion (Misc queries) 3 April 19th 08 07:29 PM


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