Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Edit cell contents via userform listbox


Hi

I have a range of cells (D2:D100) Which the user needs to edit - Th
user can only access these cells via a userform. The userfor
currently has a listbox to allow the user to see the contents of th
cells.

How can I set it up to allow the user to select a cell - edit the tex
- update the cell with the edited text?

I tried VBA help and tried AddItem etc but could not get it to edit th
cell.

Any suggestions and advice would be much appreciated!

Kenny
Win 2000 - Excel 9

--
N E Bod
-----------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...fo&userid=1126
View this thread: http://www.excelforum.com/showthread.php?threadid=27006

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Edit cell contents via userform listbox

You could use a refedit control on your userform and ask for the cell to update,
plop the value into a textbox and allow the user to edit it. Then have them
click a button to update that cell with the changes.

I used an application.inputbox to ask for the cell.

Option Explicit
Private Sub CommandButton1_Click()
Dim myCell As Range

Set myCell = Nothing
On Error Resume Next
Set myCell = Application.InputBox(prompt:="select a cell", Type:=8).Cells(1)
On Error GoTo 0

Set myCell = myCell.Parent.Cells(myCell.Row, "D")

With Me.TextBox1
.Value = myCell.Value
.Tag = myCell.Address(external:=True)
End With


End Sub
Private Sub CommandButton2_Click()

Dim myCell As Range

Set myCell = Nothing
On Error Resume Next
Set myCell = Range(Me.TextBox1.Tag)
On Error GoTo 0

If myCell Is Nothing Then
Beep
'something bad happened
Else
myCell.Value = Me.TextBox1.Value
Me.TextBox1.Value = ""
End If
End Sub

N E Body wrote:

Hi

I have a range of cells (D2:D100) Which the user needs to edit - The
user can only access these cells via a userform. The userform
currently has a listbox to allow the user to see the contents of the
cells.

How can I set it up to allow the user to select a cell - edit the text
- update the cell with the edited text?

I tried VBA help and tried AddItem etc but could not get it to edit the
cell.

Any suggestions and advice would be much appreciated!

Kenny
Win 2000 - Excel 97

--
N E Body
------------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...o&userid=11263
View this thread: http://www.excelforum.com/showthread...hreadid=270067


--

Dave Peterson

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
Have code check cell contents on edit. Andrew Excel Worksheet Functions 1 January 16th 08 04:47 AM
Edit macro to match entire cell contents nis75p06 Excel Discussion (Misc queries) 1 September 3rd 05 04:27 PM
How can I edit cell contents with a macro in Excel? Mind the gaps! Excel Discussion (Misc queries) 2 March 23rd 05 08:51 PM
How can I edit cell contents with a macro in Excel? NotAnExpert Excel Discussion (Misc queries) 1 March 23rd 05 01:17 AM
How to display contents of a cell in UserForm and take input ssexcel[_3_] Excel Programming 2 October 28th 03 12:37 AM


All times are GMT +1. The time now is 01:01 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"