Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Update Range from User Form

It seems that this shouldn't be too hard but I cannot figure it out. I
select a range of cells that may have values or may be blank. I want to
cycle through the cells and give the user a chance to accept the current
value or enter their own. I have a user form with the following code:

Private Sub UserForm_Initialize()
Dim Puzzle As Range
Dim temp As Range

Set Puzzle = Sheets("Puzzle").Range("A1:P16")

For Each temp In Puzzle
'Highlight the cell to show the user where they are
temp.Cells.Interior.ColorIndex = 6
With UserForm2
.StartUpPosition = 0
.Top = 400
.Left = 400
.TextBox1.Text = temp.Value
.TextBox1.SelStart = 0
.TextBox1.SelLength = Len(.TextBox1.Text)
.Show
End With
Next temp
End Sub

Private Sub CommandButton1_Click()
'What to put in here?
End Sub

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?

Thanks,

fybar
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
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
User Form: Cannot Update Text Box Charles in Iraq Excel Discussion (Misc queries) 0 October 12th 06 07:53 AM
user form - data range sam1[_3_] Excel Programming 4 March 28th 06 01:27 AM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
Find and Update with User Form prodsched[_7_] Excel Programming 0 May 18th 04 03:35 PM
Creating a User Form to update a list Gary Hall Excel Programming 1 January 4th 04 03:02 PM


All times are GMT +1. The time now is 10:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"