Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default How to take over the value of a userform-controle to a cell

Dear All,

I'm new at Excel-programming!

I want to show a form to input several lines of text in a cell.
I can NOT enlarge the cell.
I created a userform that shows when the cell has the focus.
BUT how do i take the value from the cell to the form-controle and back.
When opening the formcontrole must show the cell-value.
Closing the form the cell must show the form-controle-value.


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Column = 9 And Target.Row 6 Then
Frm_NOTA.Show
ActiveCell.Value = ........?????
End If
End Sub

Thanks,

Filip


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default How to take over the value of a userform-controle to a cell

In the form code you need to put an initialise eveny to 'copy' the
activecell into the form control (in this case called TextBox1), then when
the user closes the form (presses cross in top right) the value is passed
back to the active cell and the form closes.

Put the following code into the form by going to VBA editor (Alt-F11) and
select FORM from the project explorer and right- click then choose VIEW code
and paste the folllowing.....

Private Sub UserForm_Initialize()
TextBox1.Value = ActiveCell.Value
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = TextBox1.Value
Unload Me
End Sub


--
Cheers
Nigel



"Filips Benoit" wrote in message
...
Dear All,

I'm new at Excel-programming!

I want to show a form to input several lines of text in a cell.
I can NOT enlarge the cell.
I created a userform that shows when the cell has the focus.
BUT how do i take the value from the cell to the form-controle and back.
When opening the formcontrole must show the cell-value.
Closing the form the cell must show the form-controle-value.


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Column = 9 And Target.Row 6 Then
Frm_NOTA.Show
ActiveCell.Value = ........?????
End If
End Sub

Thanks,

Filip




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default How to take over the value of a userform-controle to a cell

Thanksł

"Nigel" wrote in message
...
In the form code you need to put an initialise eveny to 'copy' the
activecell into the form control (in this case called TextBox1), then when
the user closes the form (presses cross in top right) the value is passed
back to the active cell and the form closes.

Put the following code into the form by going to VBA editor (Alt-F11) and
select FORM from the project explorer and right- click then choose VIEW

code
and paste the folllowing.....

Private Sub UserForm_Initialize()
TextBox1.Value = ActiveCell.Value
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = TextBox1.Value
Unload Me
End Sub


--
Cheers
Nigel



"Filips Benoit" wrote in message
...
Dear All,

I'm new at Excel-programming!

I want to show a form to input several lines of text in a cell.
I can NOT enlarge the cell.
I created a userform that shows when the cell has the focus.
BUT how do i take the value from the cell to the form-controle and back.
When opening the formcontrole must show the cell-value.
Closing the form the cell must show the form-controle-value.


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal

Target
As Range)
If Target.Column = 9 And Target.Row 6 Then
Frm_NOTA.Show
ActiveCell.Value = ........?????
End If
End Sub

Thanks,

Filip






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to take over the value of a userform-controle to a cell

Another way

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Column = 9 And Target.Row 6 Then
Frm_NOTA.Load
Textbox1.Vakue = Target.Value
Frm_NotA.Show
Target.Value = Textbox1.Text
Un load Frm_NotA.Show
End If
End Sub

Just make sure that you hide the form in the form code, not unload it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Filips Benoit" wrote in message
...
Dear All,

I'm new at Excel-programming!

I want to show a form to input several lines of text in a cell.
I can NOT enlarge the cell.
I created a userform that shows when the cell has the focus.
BUT how do i take the value from the cell to the form-controle and back.
When opening the formcontrole must show the cell-value.
Closing the form the cell must show the form-controle-value.


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Column = 9 And Target.Row 6 Then
Frm_NOTA.Show
ActiveCell.Value = ........?????
End If
End Sub

Thanks,

Filip




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
Vba add data to cell from userform adrian Excel Programming 4 May 27th 04 08:02 AM
Userform cell reference help Pete Excel Programming 2 January 28th 04 02:20 PM
UserForm with Cell Data Phil Hageman Excel Programming 2 October 7th 03 02:02 PM
Userform/Cell formatting Todd Huttenstine Excel Programming 2 September 28th 03 11:16 PM
Userform reading a cell value Ron de Bruin Excel Programming 0 August 8th 03 12:55 PM


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