Computing.Net > Forums > Programming > VBA help with input and msgbox plz

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBA help with input and msgbox plz

Reply to Message Icon

Name: relwod14
Date: August 1, 2005 at 08:01:32 Pacific
OS: win xp
CPU/Ram: amd
Comment:

i have been doing the following coding which allows me to input through a input box 5 names this works however i would first of all like to enter the word QUIT before the 5th name is inputed so that i dont have to input anymore then the second thind i want to do is get a message box to appear after its has quit to show in numbers how many names have been put in for example if only two names have been put in before the word quit is entered i then would like a message box to appear with "2" in it. if anyone can help i would be so greatful. below is my coding


Private Sub pressHereToInputManufacturesNames_Click()

Dim manufacturersName1$
Dim manufacturersName2$
Dim manufacturersName3$
Dim manufacturersName4$
Dim manufacturersName5$
Dim i As Integer
Dim rRange As Excel.Range
Dim strtext$
Set rRange = Range("a1", Range("a1").End(xlUp))
Dim iTheRows As Long

'the below message box instructs the user to enter the word QUIT before they input a fifth
'manufacturers name the use of "&vbCrlf" in the coding forces a break in the line of the message

MsgBox "Please can you enter the word QUIT befor putting in 5 manufacturers names" & vbCrLf & "its up to you when you do it aslong as it is before the 5th name Thankyou"

With ActiveSheet
manufacturesName1 = InputBox("Manufactorsname 1")
.[a1].Value = manufacturesName1
manufacturesName2 = InputBox("Manufactorsname 2")
.[a2].Value = manufacturesName2
manufacturesName3 = InputBox("Manufactorsname 3")
.[a3].Value = manufacturesName3
manufacturesName4 = InputBox("Manufactorsname 4")
.[A4].Value = manufacturesName4
manufacturesName5 = InputBox("Manufactorsname 5")
.[a5].Value = manufacturesName5

End With

' this below section of coding selects the cells which the manufactures names have been inputted into

iTheRows = rRange.Rows.Count
[a1,a2,a3,a4,a5].Select

' the below section of coding makes another message box come up showing the manufactures names that have been inputted

'in here i want to i think put coding in to make it stop when the word quit is put into the input box

'then after this i want the message box to display as a interger how many names in total have been inputed into the cell range a1:a5


For i = 1 To iTheRows Step 1
strtext$ = strtext$ & ActiveCell.Value & vbCrLf
Next i
MsgBox strtext$

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: August 1, 2005 at 09:01:13 Pacific
Reply:

Just one question rewod14.

Is this a project you are doing for yourself or a task that has been given to you to do by a teacher.

The reason I ask is that using QUIT to terminate a process is a throw back to the days of DOS BASIC. With VB which is an event driven language in a GUI interface, it is totally unnecessary.

The job would be a whole lot easier without the necessity to enter QUIT which is archaic and a hindrance. All you need is a button on the form with a caption of QUIT and all it takes is a click of the mouse. You can then put the final bit of code into the Button_Click even of the form.

If it is a task given to you as part of a course I would find myself another instructor because this one seems to be working of fifteen year old text books.

Stuart


0

Response Number 2
Name: relwod14
Date: August 1, 2005 at 09:30:43 Pacific
Reply:

hay there stuart thankyou for your reply

the question has been given to me to do over the summer by as you gessed an old teacher he has given powerpoint sheets to us with upto date examples but are useless because he keeps trying to tell us to do it his way thats why in getting all confused im new to vba so im having alot of trouble please could you help me iv have understood so far what you have said to me and i think you are a much better teacher i have learnt more with you than ever!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBA help with input and msgbox plz

Help with C++ and Mod 11 program www.computing.net/answers/programming/help-with-c-and-mod-11-program/5553.html

Help with a velocity C program. www.computing.net/answers/programming/help-with-a-velocity-c-program/14847.html

Vba help with coding www.computing.net/answers/programming/vba-help-with-coding/13121.html