Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Two Questions

Hello World

User enters data into a form control for the purpose of generating a
manifest. I want to stop the user from entering more than 30 products
within a single userform. The controls are linked to a worksheet called
"Temp". Also on the same userform I want to be able to tell the user if any
information is missing for instance this code executes the msgbox but then
procedes with the rest of the code?

Sub Name()
Sheets("TEMP").Select
If Range("E40") = "-" Then 'Relates to a cell where information is
copied from into. "-" = product code seperator.
MsgBox "You must enter a Product Code!", vbInformation
End If
User_InputP.Show 'Userform for entering products.
'rest of code to copy and paste information into a table

TIA
Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Two Questions

A couple of methods (of numerous possibilities)

1. WHEN USER TRIES TO FINISH FORM

Code
-------------------

Sub Button1_Click()
'- check 1
If Range("A1").Value = "" Then
MsgBox ("Must enter value")
Range("A1").Select
Exit Sub
End If
'- check 2
If Range("A2").Value 100 Then
MsgBox ("Value too high")
Range("A2").Select
Exit Sub
End If
'- check 3
counter = Application.WorksheetFunction.CountA(Range("A1:A30 "))
If counter = 30 Then
MsgBox ("Cannot have more than 30 products. Please delete " & counter - 30)
Range("A31").Select
Exit Sub
End If
'- checks complete. save file
ActiveWorkbook.Save
MsgBox ("Form saved.")
End Sub

-------------------


2. IN PROCESS OF COMPLETING FORM
Using worksheet Change event

Code
-------------------

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.WorksheetFunction.CountA(Range("A1:A30 ")) = 30 Then
MsgBox ("You have reached the limit of 30 entries")
End If
End Sub

-------------------


--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Two Questions

Thank you Brian

"BrianB " wrote in message
...
A couple of methods (of numerous possibilities)

1. WHEN USER TRIES TO FINISH FORM

Code:
--------------------

Sub Button1_Click()
'- check 1
If Range("A1").Value = "" Then
MsgBox ("Must enter value")
Range("A1").Select
Exit Sub
End If
'- check 2
If Range("A2").Value 100 Then
MsgBox ("Value too high")
Range("A2").Select
Exit Sub
End If
'- check 3
counter = Application.WorksheetFunction.CountA(Range("A1:A30 "))
If counter = 30 Then
MsgBox ("Cannot have more than 30 products. Please delete " & counter -

30)
Range("A31").Select
Exit Sub
End If
'- checks complete. save file
ActiveWorkbook.Save
MsgBox ("Form saved.")
End Sub

--------------------


2. IN PROCESS OF COMPLETING FORM
Using worksheet Change event

Code:
--------------------

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.WorksheetFunction.CountA(Range("A1:A30 ")) = 30 Then
MsgBox ("You have reached the limit of 30 entries")
End If
End Sub

--------------------



---
Message posted from http://www.ExcelForum.com/



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
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
questions about at sum nreily Excel Discussion (Misc queries) 2 May 14th 09 04:27 PM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
Two questions B.Kundla Excel Discussion (Misc queries) 4 September 23rd 05 04:24 PM
VB questions Dick Kusleika Excel Programming 0 September 4th 03 09:20 PM


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