Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Change Text size on focus

Is it possible to change the text size when a cell is selected? I would like
to simulate magnifying the cell contents when a cell is progmatically
selected to draw user attention to the cell.
Upon leaving that cell the font size would revert to default (its originial
format value).

Happy New Year!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Change Text size on focus

Rick

I am not sure what you mean by programaticlly selected, but, if you
just are using the mouse to select a cell, the following
Worksheet_SelectionChange code will do what you want. Put this in the
sheet object code:

Public c As String

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range(c).Font.Size = 10
c = ActiveCell.Address
ActiveCell.Font.Size = 32
End Sub

If your cell is being selected through some other VBA code, you will
need to simply put some similar statements in the existing code. If
you by "programatically" you mean using the basic Excel program, then
this should work.

Good luck.

Ken
Norfolk, Va

On Dec 28, 4:38*pm, Rick S. wrote:
Is it possible to change the text size when a cell is selected? *I would like
to simulate magnifying the cell contents when a cell is progmatically
selected to draw user attention to the cell.
Upon leaving that cell the font size would revert to default (its originial
format value).

Happy New Year!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Change Text size on focus

Hi,
Method1
---------
Resizing the font may (will) resize the column width and the row height, so
it may create more issues than good. ANyway, the code bellow works ok.

Method2
---------
A less invasive solution would be to have a picture of the cell next to the
selected cell that show its contents in larger font.
- select an empty cell and do a Copy Picture (in xl 2003 and prior, press
SHIFT while clicking menu Edit and the new item Copy Picture shows up) as
bitmap.
- paste the picture (menu Edit Paste). Say its name is 'Picture 1'
- enlarge it a little bit
- now in the sheet module, use the code (uses the name of the picture):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim p As Excel.Picture
Set p = ActiveSheet.Pictures("picture 1")
p.Formula = "=" & ActiveCell.Address(False, False)
End Sub
- On book closing, you could just hide the picture.

Method1 - COde
-------------------
''' ########## IN SHEET ######################
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ResetToPrevious
SetTracker ActiveCell
End Sub

''' ########## IN MODULE ######################
Public Type Tracker
Range As Range
RowHeight As Double
ColumnWidth As Double
FontSize As Single
End Type

Public mPrevious As Tracker

Public Sub ResetToPrevious()
If Not mPrevious.Range Is Nothing Then ''' reset previous range if any
With mPrevious
.Range.Font.Size = .FontSize
.Range.ColumnWidth = .ColumnWidth
.Range.RowHeight = .RowHeight

Set .Range = Nothing
End With
End If
End Sub

Public Sub SetTracker(Target As Range, Optional Size As Long = 24)
Dim cell As Range
Set cell = Target.Cells(1)
With mPrevious
Set .Range = cell
.ColumnWidth = cell.ColumnWidth
.RowHeight = cell.RowHeight
.FontSize = Size

.Range.Font.Size = Size
End With

End Sub
''' #####################################
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
<http://www.ready-reports.com


"Rick S." wrote:

Is it possible to change the text size when a cell is selected? I would like
to simulate magnifying the cell contents when a cell is progmatically
selected to draw user attention to the cell.
Upon leaving that cell the font size would revert to default (its originial
format value).

Happy New Year!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Change Text size on focus

I will check these out to see which is most usefull, initial testing seems to
work for each submission.

Thanks for your help!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"sebastienm" wrote:

Hi,
Method1
---------
Resizing the font may (will) resize the column width and the row height, so
it may create more issues than good. ANyway, the code bellow works ok.

Method2
---------
A less invasive solution would be to have a picture of the cell next to the
selected cell that show its contents in larger font.
- select an empty cell and do a Copy Picture (in xl 2003 and prior, press
SHIFT while clicking menu Edit and the new item Copy Picture shows up) as
bitmap.
- paste the picture (menu Edit Paste). Say its name is 'Picture 1'
- enlarge it a little bit
- now in the sheet module, use the code (uses the name of the picture):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim p As Excel.Picture
Set p = ActiveSheet.Pictures("picture 1")
p.Formula = "=" & ActiveCell.Address(False, False)
End Sub
- On book closing, you could just hide the picture.

Method1 - COde
-------------------
''' ########## IN SHEET ######################
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ResetToPrevious
SetTracker ActiveCell
End Sub

''' ########## IN MODULE ######################
Public Type Tracker
Range As Range
RowHeight As Double
ColumnWidth As Double
FontSize As Single
End Type

Public mPrevious As Tracker

Public Sub ResetToPrevious()
If Not mPrevious.Range Is Nothing Then ''' reset previous range if any
With mPrevious
.Range.Font.Size = .FontSize
.Range.ColumnWidth = .ColumnWidth
.Range.RowHeight = .RowHeight

Set .Range = Nothing
End With
End If
End Sub

Public Sub SetTracker(Target As Range, Optional Size As Long = 24)
Dim cell As Range
Set cell = Target.Cells(1)
With mPrevious
Set .Range = cell
.ColumnWidth = cell.ColumnWidth
.RowHeight = cell.RowHeight
.FontSize = Size

.Range.Font.Size = Size
End With

End Sub
''' #####################################
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
<http://www.ready-reports.com


"Rick S." wrote:

Is it possible to change the text size when a cell is selected? I would like
to simulate magnifying the cell contents when a cell is progmatically
selected to draw user attention to the cell.
Upon leaving that cell the font size would revert to default (its originial
format value).

Happy New Year!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Change Text size on focus

Hi Rick

Place this code in the codesheet for Sheet1, and see what happens:-)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Font.Size = 10
Target.Font.Size = 20
End Sub

Happy New Year!

Per

On 28 Dec., 22:38, Rick S. wrote:
Is it possible to change the text size when a cell is selected? *I would like
to simulate magnifying the cell contents when a cell is progmatically
selected to draw user attention to the cell.
Upon leaving that cell the font size would revert to default (its originial
format value).

Happy New Year!
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007




  #6   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Change Text size on focus

Rick

If you definitely want the cell to revert to size 10 (or any uniform
size) when you leave it, go with Per's two liner. If you want it to
revert to whatever it was (allowing for a mix of sized in cells
throughout the sheet) you can use:

Public c As String
Public x As Integer

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Range(c).Font.Size = x
c = ActiveCell.Address
x = ActiveCell.Font.Size
ActiveCell.Font.Size = 32
End Sub

Change the 32 to whatever you want the "magnified" size to be. If you
don't like row heights and columns widths changing as a result of your
selection, just make sure to set them manually to something you like.

Ken

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
How do I change the size of the text in a worksheet tab? Doug New Users to Excel 2 December 22nd 08 07:14 PM
Text formatting - Change Font Size dd Excel Programming 5 February 2nd 07 10:25 AM
Change the size of text used in a Form combo box Mark Excel Discussion (Misc queries) 0 April 11th 06 03:08 PM
font size changes w/ control focus mark kubicki Excel Worksheet Functions 0 June 17th 05 06:00 PM
How do I change the text size in a drop down box Paragon Tim Excel Discussion (Misc queries) 0 April 7th 05 07:51 PM


All times are GMT +1. The time now is 06:52 PM.

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"