Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need code for transfering cell value to text box.

Need some help getting the value of a cell to show up in a text box.
The cell "C13" contains a formula that calculates it's value from 3
other cells. These cells recieve their value as data is entered into
corresponding text boxes.
I tried linking the textbox to the cell by control source but I quickly
found out that it will override the formula in the cell.

How can I get the cell value to show up in the text box? Ideally I
would like it to show up automatically when the cell's value changes,
without having to associate it with an event.
Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Need code for transfering cell value to text box.

Matt,

Below is the code which will do the work ...

Option Explicit
Private Sub TextBox1_Change()
'if Cell F5 contains the final calculation
TextBox1.Text = Range("F5").Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Call TextBox1_Change
End Sub

HTH
Carim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need code for transfering cell value to text box.

Thanks for your help Carim. The code works but not exactly as I'd
planned. TextBox1 isn't populated until I focus on it and hit any key,
then it updates.
Ideally, it would update immediately after the cells that "F5" uses for
the calculation are populated.
Clear as mud? Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Need code for transfering cell value to text box.

Matt,

For automatic update, make sure in the sheet object to have :
Private Sub Worksheet_Change(ByVal Target As Range)
Call TextBox1_Change
End Sub

Cheers

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need code for transfering cell value to text box.

Carim thanks once again. In case you can't tell I'm a novice at this
you'll know now...
Where can I find the sheet objective to insert the code?

thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Need code for transfering cell value to text box.

Matt,

Double click the sheet (the one that contains the results cell) in
project explorer (ALT + F11 to bring this up - see the left hand side
of the screen) - click on the down arrow on the box that will say
"(General)" (it's at the top of the screen on the main code window)and
you should see the word Worksheet. Click on this and the right drop
down dialogue will change the list of available declarations.

From here, click on the drop down arrow on this right dialogue box and

select CHANGE

This will bring up the code:
Private Sub Worksheet_Change(ByVal Target As Range)
End Sub

Stick the "Call Textbox1_change" code in between these two lines.

Hope this helps,

B

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
transfering cell values progressively through worksheets Mike1558 Excel Worksheet Functions 8 April 12th 10 08:10 PM
Transfering one cell of word to excel WINDMILL Excel Discussion (Misc queries) 2 November 20th 08 04:44 PM
Transfering informationfrom one cell to another garr Links and Linking in Excel 5 February 21st 05 07:20 AM
transfering information from one cell to another garr Excel Worksheet Functions 8 February 21st 05 01:28 AM
Transfering information to the next free cell in a column Chaudfeu Excel Discussion (Misc queries) 1 February 19th 05 07:18 PM


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