Z
Zigball
I need help I am unsure of what is going on. I have five userforms
and five worksheets.. and an additional worksheet for reference page.
The useforms are used to input data. There is a complex code that
denies any duplicate data to be entered into the referring worksheet,
example sheet1 is used to store userform1's data so if you enter 2
into userform1 sheet1 will not store it if 2 is already in sheet1. It
is all controlled by code stored in the userform data validation;
validate then input. The problem is that the sheets will ultimately be
hidden from view and the reference page will be left standing alone.
When I go to implement this task there is a issue of getting the
validation code to work for duplicate data. The duplicate data code
only works when the sheet that you are trying to enter data into is
open and selected????? Is there anyone who understands what I am saying
and knows a way to help me.
Example:
Private Sub Save_Click()
If ValidateData = True Then
EnterDataInWorksheet
Unload Me
With Application
If .WorksheetFunction.CountIf(.Range("a2:a100"), FirstName.Value) >= 1
Then
Unload Me
'more code...
Else
End If
'other action
End With
End If
End Sub
I tried storing the code into the save button along with the validate
data I am unsure of Private and Public?
Here is code in validate
Public Function ValidateData() As Boolean
' Returns True if the data in the user form
' is complete, False otherwise. Displays a
' message identifying the problem.
With Application
If .WorksheetFunction.CountIf(.Range("a2:a100"), FirstName.Value) >= 1
Then
MsgBox "alert duplicate data", 16, "input!"
Unload Me
'more code...
Else
End If
'other action
End With
If FirstName.Value = "" Then
MsgBox "You must enter a First Name."
ValidateData = False
Exit Function
End If
ValidateData = True
End Function
and five worksheets.. and an additional worksheet for reference page.
The useforms are used to input data. There is a complex code that
denies any duplicate data to be entered into the referring worksheet,
example sheet1 is used to store userform1's data so if you enter 2
into userform1 sheet1 will not store it if 2 is already in sheet1. It
is all controlled by code stored in the userform data validation;
validate then input. The problem is that the sheets will ultimately be
hidden from view and the reference page will be left standing alone.
When I go to implement this task there is a issue of getting the
validation code to work for duplicate data. The duplicate data code
only works when the sheet that you are trying to enter data into is
open and selected????? Is there anyone who understands what I am saying
and knows a way to help me.
Example:
Private Sub Save_Click()
If ValidateData = True Then
EnterDataInWorksheet
Unload Me
With Application
If .WorksheetFunction.CountIf(.Range("a2:a100"), FirstName.Value) >= 1
Then
Unload Me
'more code...
Else
End If
'other action
End With
End If
End Sub
I tried storing the code into the save button along with the validate
data I am unsure of Private and Public?
Here is code in validate
Public Function ValidateData() As Boolean
' Returns True if the data in the user form
' is complete, False otherwise. Displays a
' message identifying the problem.
With Application
If .WorksheetFunction.CountIf(.Range("a2:a100"), FirstName.Value) >= 1
Then
MsgBox "alert duplicate data", 16, "input!"
Unload Me
'more code...
Else
End If
'other action
End With
If FirstName.Value = "" Then
MsgBox "You must enter a First Name."
ValidateData = False
Exit Function
End If
ValidateData = True
End Function