Thread: Input box
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
FiluDlidu FiluDlidu is offline
external usenet poster
 
Posts: 66
Default Input box

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.

"Code Cage Team" wrote:

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


"FiluDlidu" wrote:

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

"FiluDlidu" wrote:

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()
Krap! Please see above for a better version
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



"Code Cage Team" wrote:

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
--
Regards,
The Code Cage Team
www.thecodecage.com/forumz