Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / October 2008

Tip: Looking for answers? Try searching our database.

Input box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FiluDlidu - 10 Oct 2008 15:32 GMT
Hi all!

I'm looking for a way to have an input box popping up in a sheet I made.  
Basically, my sheet is a learning tool that gives me words in a language and
ask me to translate them into another language.

Now, say it asks me for "horsse" to be translated into French.  I would to
code a button that would allow me to modify entries whenever I find a
mistake.  So in this case, the popup would contain "horsse" and a box where I
should type in what should replace it ("horse" in this  case), as well as
"cheval" (its French translation) with its own box where I could type, if
there is a need, a corrected version for this word as well (let's say
"cheval, chevaux", both the singular and plural versions of the word).

Thank you kindly for any thought you might put at the problem,
Feelu
The Code Cage Team - 10 Oct 2008 16:17 GMT
How would you identify the word(s) that you should have presented to you?,
would you be selecting the words manually?, would you want the word(s) that
are replaced to go in the same cell as the translation?

To be honest if you are working with a lot of text and want spell check and
be able to identify and replace all occurrences you would be better off using
MS Word!

Regards,
The Code Cage Team
www.thecodecage.com/forumz

> Hi all!
>
[quoted text clipped - 12 lines]
> Thank you kindly for any thought you might put at the problem,
> Feelu
FiluDlidu - 10 Oct 2008 16:40 GMT
> How would you identify the word(s) that you should have presented to you?

This I already took care of.  Columns A to C contain respectively source
language words, target language equivalents and a number that helps the
question generator to pick more often those I miss more often.  These three
columns are hidden and the game occurs in columns further to the right (H, if
I remember correctly, but it's not really important for my question).

Now, when the generator inputs a new word to translate, I want to be able to
correct it if I realize there might be a typo or something.  But right now, I
need to unhide A:C, find the proper spot and fix it manually, then re-hide
A:C and keep playing.  This is rather more tedious than what a button saying
"Fix mistake" would do, if only I were able to design it in such a way that
it would allow me to change both the source and target language input in the
same box...

Is this clearer???
The Code Cage Team - 10 Oct 2008 16:48 GMT
You say "generator"? how is this achieved?, if you have code for this then
please supply it where we will be able to look at adapting a spell check to
it and maybe adding an offset for the translation.

Regards,
The Code Cage Team
www.thecodecage.com/forumz

> > How would you identify the word(s) that you should have presented to you?
>
[quoted text clipped - 13 lines]
>
> Is this clearer???
FiluDlidu - 10 Oct 2008 17:17 GMT
Thing is, the code is long long long, it contains several subs and I feel
like it is neither very meaningful to my specific problem, neither very
appealing to people to look at.  If I were only getting the code to create
the popup window with two input boxes in it, then I am fairly confident I
could splice it to my work on my own, spending myself the few hours of work
it might represent instead of pushing this work onto someone else who most
likely have something better to do than trying to figure out my mess (also, I
am French speaking and the source language is French, the target language is
Hungarian and a lot of my variable names would not mean much to most people
here, so I tried to simplify my problem so that I would stand a chance to get
people interested in fixing it).

So imagine there is already a sub that inputs a value from A:A into H3 for
me to translate into H4.

I want a button in I4 that, when pressed, propose a popup window with the
value from H3 and a box beside it, where I could type any possible correction
to the value of H3, then with also the value from B:B adjacent to the cell in
A:A that contains the value of H3, with another box into which I could type
any possible correction to that value.

Then I could press 'Validate' or something like that and values from H3 and
the appropriate cells from A:B would be changed to whatever was typed into
the input box.

Can this be achieved simply?

Thank you very much for your interest,
Feelu

> You say "generator"? how is this achieved?, if you have code for this then
> please supply it where we will be able to look at adapting a spell check to
[quoted text clipped - 21 lines]
> >
> > Is this clearer???
Code Cage Team - 10 Oct 2008 21:13 GMT
You can add a command button and call this code from it:
Sub pop_up_for_cell()
Dim ib As String
ib = InputBox("The word " & Range("H3").Value & " has been found" & Chr(13) _
& "either type you correction or click ok to accept!", "Word Check",
Range("H3").Value)
Range("H4").Value = ib
End Sub
Signature

Regards,
The Code Cage Team
www.thecodecage.com/forumz

> Thing is, the code is long long long, it contains several subs and I feel
> like it is neither very meaningful to my specific problem, neither very
[quoted text clipped - 51 lines]
> > >
> > > Is this clearer???
FiluDlidu - 10 Oct 2008 21:32 GMT
Mmmh!

Two problems with this code:
1) It doesn't allow to change the target language value, were there a
mistake in it;
2) What is typed in doesn't change the value in H3, but only enters it in H4.

I found something, but it's rather tedious...  Maybe you could try it to see
what it gives:

---

To correct H3 and its equivalent in A:B

Sub change()
Application.EnableEvents = False
Dim Title, Default1, Prompt1, Corrected1, Default2, Prompt2, Corrected2
Title = "Modify errors encountered"
Default1 = Range("H3").Value
Prompt1 = Default1 & " should become: "
Corrected1 = InputBox(Prompt1, Title, Default1)
If Corrected1 = "" Then Corrected1 = Default1
Default2 = Range("A:A").Find(Default1).Offset(, 1).Value
Prompt2 = Default1 & " became " & Corrected1 & Chr(10) & Chr(10) & Chr(10) &
Default2 & " should become: "
Corrected2 = InputBox(Prompt2, Title, Default2)
If Corrected2 = "" Then Corrected2 = Default2
If Corrected1 = Default1 Then
 GoTo Target
Else: Range("A:A").Find(Default1).Value = Corrected1
 Range("H3").Value = Corrected1
End If
Target:
If Corrected2 = Default2 Then
 GoTo Last
Else: Range("A:A").Find(Corrected1).Offset(, 1).Value = Corrected2
End If
Last:
Range("H4").Select
Application.EnableEvents = True
End Sub

-----
To generate random values in H3, for us to translate into H4:

Sub enterNew()
Application.EnableEvents = False
Range("H3").Formula = "=INDEX(A:A,INT(" & Range("C1").Value & "*RAND())+1)"
Range("H3").Value = Range("H3").Value
Range("H4").Select
Application.EnableEvents = True
End Sub

---

Random stuff to put into A:C

horse    cheval    =counta(a:a)
cat    chat   
dog    chien   
raven    corbeau   
fox    renard   
wolf    loup   

> You can add a command button and call this code from it:
> Sub pop_up_for_cell()
[quoted text clipped - 4 lines]
> Range("H4").Value = ib
> End Sub
FiluDlidu - 10 Oct 2008 21:39 GMT
Well, let's put this into shorter lines...  (sorry for the sloppy first try!)

Sub change()
Application.EnableEvents = False
Dim Title, Default1, Prompt1, Corrected1, Default2, Prompt2, Corrected2
Title = "Modify errors encountered"
Default1 = Range("H3").Value
Prompt1 = Default1 & " should become: "
Corrected1 = InputBox(Prompt1, Title, Default1)
If Corrected1 = "" Then Corrected1 = Default1
Default2 = Range("A:A").Find(Default1).Offset(, 1).Value
Prompt2 = Default1 & " became " & Corrected1 & Chr(10) & Chr(10) _
 & Chr(10) & Default2 & " should become: "
Corrected2 = InputBox(Prompt2, Title, Default2)
If Corrected2 = "" Then Corrected2 = Default2
If Corrected1 = Default1 Then
 GoTo Target
Else: Range("A:A").Find(Default1).Value = Corrected1
 Range("H3").Value = Corrected1
End If
Target:
If Corrected2 = Default2 Then
 GoTo Last
Else: Range("A:A").Find(Corrected1).Offset(, 1).Value = Corrected2
End If
Last:
Range("H4").Select
Application.EnableEvents = True
End Sub

> Mmmh!
>
[quoted text clipped - 44 lines]
> > Range("H4").Value = ib
> > End Sub
Code Cage Team - 11 Oct 2008 00:54 GMT
Nothing wrong with either of those codes, both do what you expected:
Sub change1()
Application.EnableEvents = False
Dim Default1, Corrected1, Default2, Corrected2
Default1 = Range("H3").Value
Default2 = Range("A:A").Find(Default1).Offset(, 1).Value
Corrected1 = InputBox(Default1 & " should become: ", "Modify errors
encountered", Default1)
If Corrected1 = "" Then Corrected1 = Default1
Corrected2 = InputBox(Default1 & " became " & Corrected1 & Chr(10) & Chr(10) _
& Chr(10) & Default2 & " should become: ", "Modify errors encountered",
Default2)
       If Corrected2 = "" Then Corrected2 = Default2
           If Corrected1 = Default1 Then
               GoTo Target
           Else: Range("A:A").Find(Default1).Value = Corrected1
               Range("H3").Value = Corrected1
           End If
Target:
If Corrected2 = Default2 Then
   GoTo Last
       Else: Range("A:A").Find(Corrected1).Offset(, 1).Value = Corrected2
End If
Last:
Range("H4").Select
Application.EnableEvents = True
End Sub
Regards,
The Code Cage Team
www.thecodecage.com/forumz

> Well, let's put this into shorter lines...  (sorry for the sloppy first try!)
>
[quoted text clipped - 74 lines]
> > > Range("H4").Value = ib
> > > End Sub
FiluDlidu - 11 Oct 2008 02:06 GMT
Yes and no...  I still don't like the way it's bringing the user through two
input boxes rather than only one where both fixes could be made at once.

> Nothing wrong with either of those codes, both do what you expected:
> Sub change1()
[quoted text clipped - 105 lines]
> > > > Range("H4").Value = ib
> > > > End Sub
Code Cage Team - 11 Oct 2008 04:40 GMT
You will have to create a userform, add two textboxes and a command button,
once you have done that double click the command button and drop this in:
Private Sub CommandButton1_Click()
Dim rFound As String
rFound =
ActiveWorkbook.Sheets("Sheet1").Range("A:A").Find(What:=ActiveWorkbook.Sheets("Sheet1").Range("H3").Value, _
After:=ActiveWorkbook.Sheets("Sheet1").Range("A1"), LookIn:=xlFormulas,
LookAt:= _
       xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
       , SearchFormat:=False).Address
       Range(rFound).Value = Me.TextBox1.Value
       Range(rFound).Offset(0, 1).Value = Me.TextBox2.Value

 Unload Me
End Sub
Private Sub UserForm_Initialize()
Me.TextBox1.Value = ActiveWorkbook.Sheets("Sheet1").Range("H3").Value
Me.TextBox2.Value =
ActiveWorkbook.Sheets("Sheet1").Range("A:A").Find(What:=ActiveWorkbook.Sheets("Sheet1") _
.Range("H3").Value, After:=ActiveWorkbook.Sheets("Sheet1").Range("A1"),
LookIn:=xlFormulas, LookAt:= _
       xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
       , SearchFormat:=False).Offset(0, 1)
End Sub

Then use this for your random:
Sub enterNew()
Application.EnableEvents = False
Range("H3").Formula = "=INDEX(A:A,INT(" & Range("C1").Value & "*RAND())+1)"
Range("H3").Value = Range("H3").Value
Application.EnableEvents = True
UserForm1.Show
End Sub

Now you can make changes in the Textboxes and when clicking the
commandbutton the changes get made to those cells!
Signature

Regards,
The Code Cage Team
www.thecodecage.com/forumz

> Yes and no...  I still don't like the way it's bringing the user through two
> input boxes rather than only one where both fixes could be made at once.
[quoted text clipped - 108 lines]
> > > > > Range("H4").Value = ib
> > > > > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.