Update Range from User Form
On Sat, 01 Apr 2006 21:50:21 GMT, fybar wrote:
I had the Range setting code and For loop in the Sheet1 section and I got
the loop to work. It would bring up a form and show the value and I would
cycle through the forms by closing them with the X. Now, I moved this to
the userform as I thought it would need to be there to get a value from the
user to update the cell. How do I cycle through the range and accept or
change values by hitting the Enter button? Also, I want to just use one
form to do this, it seems more sensible.
Is there a better or more acceptable way to do this?
Ok, following up on my own post. I figured out how to do this. In the
Sheet1 code area I have this for a button on the sheet:
Private Sub cmdClearPuzzle_Click()
UserForm2.Show
Dim Puzzle As Range
Dim temp As Range
Set Puzzle = Sheets("Puzzle").Range("A1:P16")
For Each temp In Puzzle
temp.Cells.Interior.ColorIndex = 6
temp.Cells.Activate
With UserForm2
.StartUpPosition = 0
.Top = 400
.Left = 400
.TextBox1.Text = temp.Cells.Value
.TextBox1.SelStart = 0
.TextBox1.SelLength = Len(.TextBox1.Text)
.Show
End With
Next temp
End Sub
And in the userform code area:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
ActiveCell.Value = Me.TextBox1.Value
ActiveCell.Interior.ColorIndex = 0
Me.Hide
End If
End Sub
This works exactly as I want it to. Does this seem like the best way to
accomplish this? If anyone has any suggestion I would welcome them.
Thanks,
fybar
|