PC Review


Reply
Thread Tools Rate Thread

"ColumnOverflow" Function?

 
 
PeteCresswell
Guest
Posts: n/a
 
      19th Oct 2009
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?
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      19th Oct 2009
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" <(E-Mail Removed)> wrote in message
news:abb960c4-39c9-4d3d-8aee-(E-Mail Removed)...
> 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?


 
Reply With Quote
 
(PeteCresswell)
Guest
Posts: n/a
 
      20th Oct 2009
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
 
Reply With Quote
 
PeteCresswell
Guest
Posts: n/a
 
      25th Oct 2009
> 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
---------------------------------------------------------

 
Reply With Quote
 
PeteCresswell
Guest
Posts: n/a
 
      25th Oct 2009
> 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.
 
Reply With Quote
 
PeteCresswell
Guest
Posts: n/a
 
      26th Oct 2009
On Oct 25, 10:43*am, PeteCresswell <petecr...@gmail.com> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"replace" and "Find" function in Microsoft Office Word 2003 =?Utf-8?B?bWxlaA==?= Microsoft Access 1 10th May 2006 11:12 PM
Text "comparison" operator for "contains" used in an "IF" Function =?Utf-8?B?UGF3YXNv?= Microsoft Excel Worksheet Functions 3 19th Jan 2006 06:42 PM
Please add a "sheet" function like "row" and "column" functions =?Utf-8?B?U3ByZWFkc2hlZXQgTW9ua2V5?= Microsoft Excel Programming 2 8th Nov 2005 04:08 PM
Replace "insert function" with "edit formula" button in fourmula b =?Utf-8?B?MTNicmlhbg==?= Microsoft Excel Misc 0 24th Aug 2005 08:49 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 AM.