+ Reply to Thread
Results 1 to 4 of 4

vba solutions a.s.a.p please

  1. #1
    Registered User
    Join Date
    07-31-2005
    Posts
    7

    Arrow vba solutions a.s.a.p please

    i have been given the following questions if anyone could help with a solution to each i would be most greatful because i am new to using vba in excel and im finding is all very confusing

    1) produce code that allows a user to input using a input box up to but no more than five manufactures names. to finish entry before five manufactures names have been entered the user should input the word QUIT. after entry is complete the number of names inputed by the user should be displayed in a message box

    2) desgin a excel spreadsheet that will allow the registration of votes for the big listen. voters will be allowed to lodge votes for one of five radio programmes. the form should include a cell to allow the entry of a vote(1-5) and a button, cmdSubmit to submit this. the data must be held in an arry. the form should also include display the radio programm names, radio programm numbers and the current score

    3)write a function to test whether an integer lies between 0 and 100. this should return a boolean value

    kind regards

    relwod

  2. #2
    Tim Williams
    Guest

    Re: vba solutions a.s.a.p please

    Homework ?

    Perhaps you could post what you've tried so far.

    Tim.


    "RELWOD85" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > i have been given the following questions if anyone could
    > help with a solution to each i would be most greatful because i am
    > new
    > to using vba in excel and im finding is all very confusing
    >
    > 1) produce code that allows a user to input using a input box up to
    > but
    > no more than five manufactures names. to finish entry before five
    > manufactures names have been entered the user should input the word
    > QUIT. after entry is complete the number of names inputed by the
    > user
    > should be displayed in a message box
    >
    > 2) desgin a excel spreadsheet that will allow the registration of
    > votes
    > for the big listen. voters will be allowed to lodge votes for one
    > of
    > five radio programmes. the form should include a cell to allow the
    > entry of a vote(1-5) and a button, cmdSubmit to submit this. the
    > data
    > must be held in an arry. the form should also include display the
    > radio programm names, radio programm numbers and the current score
    >
    > 3)write a function to test whether an integer lies between 0 and
    > 100.
    > this should return a boolean value
    >
    > kind regards
    >
    > relwod
    >
    >
    > --
    > RELWOD85
    > ------------------------------------------------------------------------
    > RELWOD85's Profile:
    > http://www.excelforum.com/member.php...o&userid=25753
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=391644
    >




  3. #3
    Registered User
    Join Date
    07-31-2005
    Posts
    7

    what iv done so far

    for question one

    Private Sub pressHereToInputManufacturesNames_Click()
    Dim manufacturesName1 As String
    Dim manufacturesName2 As String
    Dim manufacturesName3 As String
    Dim manufacturesName4 As String
    Dim manufacturesName5 As String
    Dim i As Integer
    Dim QUIT As String

    QUIT = 4

    Do
    Range("a1").Select
    manufacturesName1 = ActiveCell.Value

    Range("a2").Select
    manufacturesName2 = ActiveCell.Value

    Range("a3").Select
    manufacturesName3 = ActiveCell.Value

    Range("a4").Select
    manufacturesName4 = ActiveCell.Value

    Range("a5").Select
    manufacturesName5 = ActiveCell.Value



    For i = 1 To 1


    manufacturesName = InputBox("Enter a manufactures name")

    Loop

    If manufacturesName = QUIT Then
    endloop

    End If

    Next i

    'MsgBox 'this should display the manufactures names that have been inouted


    End Sub

  4. #4
    NickHK
    Guest

    Re: vba solutions a.s.a.p please

    RELWOD85,
    A few comments on your code:
    Saving the names to a sheet was not part of your criteria, but it would be
    bit pointless to enter the names and just forget them.

    1. You "Dim QUIT As String", but them assign QUIT the value 4, a number.
    Whilst VBA will let you do this, what do mean by it.

    2. "manufacturesName1 = ActiveCell.Value" sets the value of
    manufacturesName1 to that of the active cell, which in a new sheet I guess
    would be "".
    What you mean is the opposite: ActiveCell.Value=manufacturesName1

    3. On the Range object, you can use .Offset within the loop, so selection
    is not required. Select is seldom required in VBA.(Hint:
    Range("A1).Offset(i,0).Value=)

    4. Your Do...Loop and For...Next are interleaved: if you had tried this
    code, you would have seen a compile error, "Do without Loop", I would guess.

    5. endloop ? Exit Do ?

    6. For i = 1 To 1: How many times does this execute ?

    7. Read about the MsgBox syntax in help. You will need to know the number
    times that the loop has executed (Hint: what is the value of i) and add this
    to you prompt text.

    8. "If manufacturesName = QUIT" ; what is the value of QUIT ?

    9. What if the user clicks the Cancel button ?

    You should at least try to run your code before you post. The help would
    have explained some of the above and VBA would have errored on the
    syntax/compile errors.
    Have another go and see what you can up with, making sure it can actually
    run. Post back and we'll make comments

    NickHK


    "RELWOD85" <[email protected]> wrote in
    message news:[email protected]...
    >
    > for question one
    >
    > Private Sub pressHereToInputManufacturesNames_Click()
    > Dim manufacturesName1 As String
    > Dim manufacturesName2 As String
    > Dim manufacturesName3 As String
    > Dim manufacturesName4 As String
    > Dim manufacturesName5 As String
    > Dim i As Integer
    > Dim QUIT As String
    >
    > QUIT = 4
    >
    > Do
    > Range("a1").Select
    > manufacturesName1 = ActiveCell.Value
    >
    > Range("a2").Select
    > manufacturesName2 = ActiveCell.Value
    >
    > Range("a3").Select
    > manufacturesName3 = ActiveCell.Value
    >
    > Range("a4").Select
    > manufacturesName4 = ActiveCell.Value
    >
    > Range("a5").Select
    > manufacturesName5 = ActiveCell.Value
    >
    > For i = 1 To 1
    >
    > manufacturesName = InputBox("Enter a manufactures name")
    >
    > Loop
    >
    > If manufacturesName = QUIT Then
    > endloop
    >
    > End If
    >
    > Next i
    >
    > 'MsgBox 'this should display the manufactures names that have been inouted
    >
    > End Sub
    >
    > RELWOD85
    > ------------------------------------------------------------------------
    > RELWOD85's Profile:

    http://www.excelforum.com/member.php...o&userid=25753
    > View this thread: http://www.excelforum.com/showthread...hreadid=391644
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1