Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default "ColumnOverflow" Function?

I'm in MS Access VBA, creating a spreadsheet.

Is there any way for me to determine if I have populated a numeric
column with too many digits tb rendered?

i.e. the sheet will show something like "#########" in the column?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default "ColumnOverflow" Function?

I don't work with Access, so I don't know if this can be translated over to
your environment or not; however, from code within Excel, you can test the
Text property of a cell to see if the number fits or not. For example,
something like this...

MsgBox "Column too narrow? " & (Left(Range("H1").Text, 1) = "#")

--
Rick (MVP - Excel)


"PeteCresswell" wrote in message
...
I'm in MS Access VBA, creating a spreadsheet.

Is there any way for me to determine if I have populated a numeric
column with too many digits tb rendered?

i.e. the sheet will show something like "#########" in the column?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default "ColumnOverflow" Function?

Per Rick Rothstein:
I don't work with Access, so I don't know if this can be translated over to
your environment or not; however, from code within Excel, you can test the
Text property of a cell to see if the number fits or not. For example,
something like this...

MsgBox "Column too narrow? " & (Left(Range("H1").Text, 1) = "#")


That'll work - 97% certain.

I'll give it a shot.

Thanks!
--
PeteCresswell
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default "ColumnOverflow" Function?

That'll work - 97% certain.

Make that 100% - but only for fields that render "#" when overflowed.
(i.e. Numeric and Date/Time).

Now, how about a plain old Text field?

e.g. .ColumnWidth = 5, but .Value = "Octagon Enhanced Loan Fund -
Wachovia".

The text renders OK as far as the column goes, but is truncated.

Any way to identify that situation?

Here's the code I have so far, which seems to deal with Numered/Date/
Time successfully:
---------------------------------------------------------
Sub ExpandColumns()
Dim curCell As Range

Dim lastRow As Long
Dim lastCol As Long
Dim lastCell As Long

Dim i As Long
Dim R As Long
Dim C As Long

Dim curWid As Double

Const incWid As Double = 0.1
Const maxWid As Long = 50

Application.ScreenUpdating = False

If WorksheetFunction.CountA(Cells) 0 Then
lastCol = Cells.Find(What:="*", After:=[A1],
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row

For R = 1 To lastRow
For C = 1 To lastCol
curWid = Columns(C).Width
Set curCell = Cells(R, C)

If Left(curCell.Text, 1) = "#" Then
Do Until Left(curCell.Text, 1) < "#"
curWid = curWid + incWid
Columns(C).ColumnWidth = curWid / 10
Loop
End If
Next C
Next R

Application.ScreenUpdating = True
Set curCell = Nothing
End If
End Sub
---------------------------------------------------------

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default "ColumnOverflow" Function?

Now, how about a plain old Text field?

I figure it's got tb something that involves converting whatever units
Column.ColumnWidth returns to the actual width of the text expressed
in pixels, points or whatever Excel uses instead of number of
characters.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default "ColumnOverflow" Function?

On Oct 25, 10:43*am, PeteCresswell wrote:
Now, how about a plain old Text field?


I figure it's got tb something that involves converting whatever units
Column.ColumnWidth returns to the actual width of the text expressed
in pixels, points or whatever Excel uses instead of number of
characters.


I'm going to spawn another thread on this.

"How To Determine Length Of Variable-Font Text?"
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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel 2003: Conditional Formatting using "MIN" & "MAX" function MMangen Excel Discussion (Misc queries) 2 September 16th 08 07:13 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM


All times are GMT +1. The time now is 04:21 AM.

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"