Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default small easy userform

i got a userform. with a cmdbuton on a sheet named "verify" column a down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers. i need
the folowing code. 1 when i click the cmdbuton it needs to call the userform.
2 when it opens up in one block randomly go and pick a word from column a. 3
the user enter a 4 number combination. click the okay buton it verify that
the number combination is in fact the one next to the word picked from colmn
a. then run macro "editsheet"
phillip
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default small easy userform

Don't bother with a a form, just use an inputbox

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 4 + 1)
mpWord = Cells(mpRow, "A").Value

mpResult = InputBox("provide a number for " & mpWord)
If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
End If

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
i got a userform. with a cmdbuton on a sheet named "verify" column a down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers. i
need
the folowing code. 1 when i click the cmdbuton it needs to call the
userform.
2 when it opens up in one block randomly go and pick a word from column a.
3
the user enter a 4 number combination. click the okay buton it verify that
the number combination is in fact the one next to the word picked from
colmn
a. then run macro "editsheet"
phillip



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default small easy userform

thats almost what i needed... thanx

it needs to randomly pick a row between 1 and 50 from colum a. then check
that the number enterd match the row from what it picked the word.

and if possible delete the word it picked?... (i know im streching my luck
now...)

o. and the cancell button dont work. i get a error message on that

thanx bob

phillip

"Bob Phillips" wrote:

Don't bother with a a form, just use an inputbox

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 4 + 1)
mpWord = Cells(mpRow, "A").Value

mpResult = InputBox("provide a number for " & mpWord)
If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
End If

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
i got a userform. with a cmdbuton on a sheet named "verify" column a down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers. i
need
the folowing code. 1 when i click the cmdbuton it needs to call the
userform.
2 when it opens up in one block randomly go and pick a word from column a.
3
the user enter a 4 number combination. click the okay buton it verify that
the number combination is in fact the one next to the word picked from
colmn
a. then run macro "editsheet"
phillip




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default small easy userform

If you get all of this in the right place and build your user form correctly,
it works.
For you worksheet command button, use the Control Toolbox and NOT the Forms
Toolbar to avoid error message.

This code goes in your worksheet module.

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Create a UserForm with a label and a command button
and put this code in the UserForm code module.

Private Sub UserForm1_Initialize()
Worksheets("verify").CommandButton1.Visible = False
tVal = Worksheets("verify").Range("A" & int((50*Rnd) + 1))
UserForm1.Label1.Text = tVal
End Sub

Put this code in the code module of the command button on the
UserForm

Private Sub CommandButton1_Click()
fVal = UserForm1.Label1.Caption
Unload UserForm1
cMatch = InputBox("Enter a four digit number combination", "Enter Match
Data")
If CLng(cMatch) = Worksheets("verify").Range("A1:A50").Find(fVal,
LookIn:=xlValues).Offset(0, 1).Value Then
Call editsheet
Else
MsgBox "No match"
Exit Sub
End If
Worksheets("verify").CommandButton1.Visible = True
End Sub

"pswanie" wrote:

thats almost what i needed... thanx

it needs to randomly pick a row between 1 and 50 from colum a. then check
that the number enterd match the row from what it picked the word.

and if possible delete the word it picked?... (i know im streching my luck
now...)

o. and the cancell button dont work. i get a error message on that

thanx bob

phillip

"Bob Phillips" wrote:

Don't bother with a a form, just use an inputbox

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 4 + 1)
mpWord = Cells(mpRow, "A").Value

mpResult = InputBox("provide a number for " & mpWord)
If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
End If

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
i got a userform. with a cmdbuton on a sheet named "verify" column a down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers. i
need
the folowing code. 1 when i click the cmdbuton it needs to call the
userform.
2 when it opens up in one block randomly go and pick a word from column a.
3
the user enter a 4 number combination. click the okay buton it verify that
the number combination is in fact the one next to the word picked from
colmn
a. then run macro "editsheet"
phillip




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default small easy userform

P.S. If for some reason you decide to format your data in column B as text,
then you will need to delete the CLng from the CLng(cMatch) phrase and make
it just cMatch which gives a text data type.

"pswanie" wrote:

thats almost what i needed... thanx

it needs to randomly pick a row between 1 and 50 from colum a. then check
that the number enterd match the row from what it picked the word.

and if possible delete the word it picked?... (i know im streching my luck
now...)

o. and the cancell button dont work. i get a error message on that

thanx bob

phillip

"Bob Phillips" wrote:

Don't bother with a a form, just use an inputbox

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 4 + 1)
mpWord = Cells(mpRow, "A").Value

mpResult = InputBox("provide a number for " & mpWord)
If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
End If

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
i got a userform. with a cmdbuton on a sheet named "verify" column a down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers. i
need
the folowing code. 1 when i click the cmdbuton it needs to call the
userform.
2 when it opens up in one block randomly go and pick a word from column a.
3
the user enter a 4 number combination. click the okay buton it verify that
the number combination is in fact the one next to the word picked from
colmn
a. then run macro "editsheet"
phillip






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default small easy userform

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 25 + 1)
mpWord = Cells(mpRow, "A").Value

On Error Resume Next
mpResult = InputBox("provide a number for " & mpWord)
On Error GoTo 0
If mpResult < 0 Then

If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
Else

Cells(mpRow, "A").Value = ""
End If
End If
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
thats almost what i needed... thanx

it needs to randomly pick a row between 1 and 50 from colum a. then check
that the number enterd match the row from what it picked the word.

and if possible delete the word it picked?... (i know im streching my luck
now...)

o. and the cancell button dont work. i get a error message on that

thanx bob

phillip

"Bob Phillips" wrote:

Don't bother with a a form, just use an inputbox

Sub Test()
Dim mpRow As Long
Dim mpWord As String
Dim mpResult As Double

mpRow = Int(Rnd() * 4 + 1)
mpWord = Cells(mpRow, "A").Value

mpResult = InputBox("provide a number for " & mpWord)
If mpResult < Cells(mpRow, "B").Value Then

MsgBox "Wrong"
End If

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"pswanie" wrote in message
...
i got a userform. with a cmdbuton on a sheet named "verify" column a
down i
got 50 words. and column b i got 50 difrent combinations of 4 numbers.
i
need
the folowing code. 1 when i click the cmdbuton it needs to call the
userform.
2 when it opens up in one block randomly go and pick a word from column
a.
3
the user enter a 4 number combination. click the okay buton it verify
that
the number combination is in fact the one next to the word picked from
colmn
a. then run macro "editsheet"
phillip






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
Easy Reading - large number minus small number MUTTMIND New Users to Excel 5 February 5th 09 10:08 AM
ISERROR,SMALL,INDEX, MATCH, SMALL?? M.A.Tyler Excel Discussion (Misc queries) 1 May 2nd 07 04:08 AM
Is there an easy Copy/Paste of a Userform ? (Entire Userform Including tx & cbx's) Corey Excel Programming 2 January 9th 07 01:01 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
Easy Userform question David Jensen Excel Programming 2 April 16th 04 01:19 AM


All times are GMT +1. The time now is 10:19 PM.

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"