Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Inserting last calculated cell's value to text box

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Inserting last calculated cell's value to text box

Put this event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
Dim v As Variant
Set b9 = Range("B9")
Set act = ActiveCell
v = b9.Value
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = v
act.Select
End Sub

It places the last calculated value of cell B9 in the textbox.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Inserting last calculated cell's value to text box

Thanks Gary''s Student for your solution. Here is what I did. I took advice
from this code:

'Option Explicit

'Dim rngLast As Range

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'If Not rngLast Is Nothing Then
'MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
'"Last Address: " & rngLast.Address(0, 0)
'End If
'Set rngLast = Target
'End Sub
'http://www.pcreview.co.uk/forums/thread-1008656.php

and modified it for my solution:

Option Explicit

Dim rngLast As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Not rngLast Is Nothing Then
ActiveSheet.Shapes("TextBox 1").Select
Selection.Characters.Text = rngLast(1, 6).Value
End If
Set rngLast = Target
rngLast.Select
End Sub

As I am novice in vba, therefore the above code is based on trial and
error. The code did the trick although not quite what was required, i.e.,
last calculated cell.

The code is not perfect and I would like helping hands to make it run faster
and strip it off the unnecessay code.

Your help is requested.

"Gary''s Student" wrote:

Put this event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
Dim v As Variant
Set b9 = Range("B9")
Set act = ActiveCell
v = b9.Value
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = v
act.Select
End Sub

It places the last calculated value of cell B9 in the textbox.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Inserting last calculated cell's value to text box

I also got here "http://www.rondebruin.nl/shape.htm" to resolve slow speed of
code but haven't got far. Have no idea what to do.


"shabutt" wrote:

Thanks Gary''s Student for your solution. Here is what I did. I took advice
from this code:

'Option Explicit

'Dim rngLast As Range

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'If Not rngLast Is Nothing Then
'MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
'"Last Address: " & rngLast.Address(0, 0)
'End If
'Set rngLast = Target
'End Sub
'http://www.pcreview.co.uk/forums/thread-1008656.php

and modified it for my solution:

Option Explicit

Dim rngLast As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Not rngLast Is Nothing Then
ActiveSheet.Shapes("TextBox 1").Select
Selection.Characters.Text = rngLast(1, 6).Value
End If
Set rngLast = Target
rngLast.Select
End Sub

As I am novice in vba, therefore the above code is based on trial and
error. The code did the trick although not quite what was required, i.e.,
last calculated cell.

The code is not perfect and I would like helping hands to make it run faster
and strip it off the unnecessay code.

Your help is requested.

"Gary''s Student" wrote:

Put this event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
Dim v As Variant
Set b9 = Range("B9")
Set act = ActiveCell
v = b9.Value
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = v
act.Select
End Sub

It places the last calculated value of cell B9 in the textbox.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Inserting last calculated cell's value to text box

Now we are getting close!

Tell me what the (1,6) means in the:

Selection.Characters.Text = rngLast(1, 6).Value

statement.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Thanks Gary''s Student for your solution. Here is what I did. I took advice
from this code:

'Option Explicit

'Dim rngLast As Range

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'If Not rngLast Is Nothing Then
'MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
'"Last Address: " & rngLast.Address(0, 0)
'End If
'Set rngLast = Target
'End Sub
'http://www.pcreview.co.uk/forums/thread-1008656.php

and modified it for my solution:

Option Explicit

Dim rngLast As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Not rngLast Is Nothing Then
ActiveSheet.Shapes("TextBox 1").Select
Selection.Characters.Text = rngLast(1, 6).Value
End If
Set rngLast = Target
rngLast.Select
End Sub

As I am novice in vba, therefore the above code is based on trial and
error. The code did the trick although not quite what was required, i.e.,
last calculated cell.

The code is not perfect and I would like helping hands to make it run faster
and strip it off the unnecessay code.

Your help is requested.

"Gary''s Student" wrote:

Put this event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
Dim v As Variant
Set b9 = Range("B9")
Set act = ActiveCell
v = b9.Value
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = v
act.Select
End Sub

It places the last calculated value of cell B9 in the textbox.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Inserting last calculated cell's value to text box

When you refer to a range like this, it's one based.

It's the equivalent of:
rnglast.cells(1,6)
or
rnglast.offset(0,5)
(notice the numbers changed)

Chip Pearson has some notes written by Alan Beban that show some other ways to
address ranges:
http://www.cpearson.com/excel/cells.htm

Gary''s Student wrote:

Now we are getting close!

Tell me what the (1,6) means in the:

Selection.Characters.Text = rngLast(1, 6).Value

statement.
--
Gary''s Student - gsnu200828

"shabutt" wrote:

Thanks Gary''s Student for your solution. Here is what I did. I took advice
from this code:

'Option Explicit

'Dim rngLast As Range

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'If Not rngLast Is Nothing Then
'MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
'"Last Address: " & rngLast.Address(0, 0)
'End If
'Set rngLast = Target
'End Sub
'http://www.pcreview.co.uk/forums/thread-1008656.php

and modified it for my solution:

Option Explicit

Dim rngLast As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Not rngLast Is Nothing Then
ActiveSheet.Shapes("TextBox 1").Select
Selection.Characters.Text = rngLast(1, 6).Value
End If
Set rngLast = Target
rngLast.Select
End Sub

As I am novice in vba, therefore the above code is based on trial and
error. The code did the trick although not quite what was required, i.e.,
last calculated cell.

The code is not perfect and I would like helping hands to make it run faster
and strip it off the unnecessay code.

Your help is requested.

"Gary''s Student" wrote:

Put this event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
Dim v As Variant
Set b9 = Range("B9")
Set act = ActiveCell
v = b9.Value
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = v
act.Select
End Sub

It places the last calculated value of cell B9 in the textbox.
--
Gary''s Student - gsnu200828


"shabutt" wrote:

Hi community members,

I have a text box in a sheet in which i want to automatically show the
result of last calculated cell's value. Any help will be most appreciated.

Regards.


--

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
Inserting a calculated field in a Pivot Table in Excel 2003 Nadine Excel Worksheet Functions 1 April 6th 10 10:37 PM
inserting a calculated field in a pivot table. John B Excel Discussion (Misc queries) 0 April 6th 09 09:29 PM
How to replace a cell's formula with a non-zero calculated value? medecin Excel Worksheet Functions 1 June 3rd 08 08:45 PM
Why calculated cell's value not updated when I change cell valueusing ado.net? DAXU Excel Programming 1 February 21st 08 03:55 PM
How do I use a cell's text, "A1", and put it in a formula? HighRiser Excel Worksheet Functions 1 July 6th 05 04:11 PM


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