Hello Dave,
I do have a userform. What I need to do is to have a warning popping out
whenever a "double input" is made. As sometimes a double input is possible,
I need to find a way to show both inputs and then give the operator a
choice: delete or keep and then go back to the input userform. As I work
with people who are not used to computers (yep, they do exist... at least
they do here in Italy) I therefor need to make sure that the only answer
possible is yes/no.
thanks
"Dave Peterson" <ec35720@netscapeXSPAM.com> wrote in message
news:41D81225.3A9A0010@netscapeXSPAM.com...
> One way to see if all 7 values match is to use an array formula like:
>
> =MATCH(1,((A2:A10="a")*(B2:B10="b")*(C2:C10="C")*(D2:D10="d")*(E2:E10="e")
> *(F2:F10="f")*(G2:G10="g")),0)
>
> (You'd hit ctrl-shift-enter instead of just enter)
>
> You could build a userform that accepts input for the 7 columns, then
> validates
> it before you continue.
>
> Debra Dalgleish has a get started with userforms instruction at:
> http://www.contextures.com/xlUserForm01.html
>
> I put a simple userform together that had 7 textboxes (textbox1 through
> textbox7) and two buttons (ok and cancel).
>
> Then I had a macro like this (in a general module) to show the form:
>
> Option Explicit
> Sub testme()
> UserForm1.Show
> End Sub
>
> Behind the userform, I had this code. Maybe it'll get you started...
>
> Option Explicit
> Private Sub CommandButton1_Click()
> 'cancel button
> Unload Me
> End Sub
> Private Sub CommandButton2_Click()
> 'ok button
> Dim iCtr As Long
> Dim ErrorFound As Boolean
> Dim DestCell As Range
> Dim myFormula As String
> Dim LastRow As Long
> Dim FirstRow As Long
>
> ErrorFound = False
> For iCtr = 1 To 7
> With Me.Controls("textbox" & iCtr)
> If .Value = "" Then
> ErrorFound = True
> .SetFocus
> Exit For
> End If
> End With
> Next iCtr
>
> If ErrorFound Then
> 'do nothing
> Else
> With Worksheets("sheet1")
> FirstRow = 2 'headers in row 1??
> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
>
> myFormula = ""
> For iCtr = 1 To 7
> myFormula = myFormula & "*(" & .Range(.Cells(FirstRow,
> iCtr), _
> .Cells(LastRow, iCtr)).Address & "=" &
> Chr(34) _
> & Me.Controls("textbox" & iCtr) & Chr(34) &
> ")"
> Next iCtr
> myFormula = Mid(myFormula, 2)
> myFormula = "match(1,(" & myFormula & "),0)"
> Debug.Print myFormula
> If IsError(.Evaluate(myFormula)) Then
> 'ok to add
> Set DestCell = .Cells(LastRow + 1, "A")
> For iCtr = 1 To 7
> DestCell.Offset(0, iCtr - 1).Value _
> = Me.Controls("textbox" & iCtr).Value
> Me.Controls("textbox" & iCtr).Value = ""
> Next iCtr
> Else
> MsgBox "already exists, can't add"
> End If
> End With
> End If
>
> End Sub
>
> Mauro wrote:
>>
>> My worksheet has 7 columns. I need a way to warn the user that the last
>> inserted data has already been inserted (this if ALL 7 columns are
>> exactely
>> the same), the same warning should present both entries and then a check
>> box
>> that, if selected, erases the duplicated row and then, at last, returns
>> to
>> userform 1 (this to continue with the work). Is it possible to create
>> something like this in excel?
>> thanks again
>
> --
>
> Dave Peterson
Bookmarks