Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default formatting cells script/marco

I'm writing data into an excel document using c# but the result is not
really what I want. All my integer/double data is written as strings. When I
open the document an optionicon is displayed on the columns holding
"misformatted data" allowing me to convert all integer-but-string-formatted
data into proper integer data (same for double). Now as I don't want do this
on every column that needs "fixing" I would like to have a script or macro
in excel that would perform this task for me - on loading or saving the
document.

Is this possible, and as I actually does not know any VB or excel macro,
does anyone have an example that I could easily use or extend?

Jan Agermose


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default formatting cells script/marco

Something like this:

Dim myCell As Range
Dim myRng As Range

With Worksheets("sheet1")
Set myRng = Intersect(.UsedRange, .Range("a:c,e:f,h:h"))
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Copy
myRng.PasteSpecial operation:=xlPasteSpecialOperationAdd
End With

It's the equivalent of copying an empty cell
and paste|special|and checking add
to all those cells that have numbers formatted as text.

Maybe in your auto_open/workbook_open code?


Jan Agermose wrote:

I'm writing data into an excel document using c# but the result is not
really what I want. All my integer/double data is written as strings. When I
open the document an optionicon is displayed on the columns holding
"misformatted data" allowing me to convert all integer-but-string-formatted
data into proper integer data (same for double). Now as I don't want do this
on every column that needs "fixing" I would like to have a script or macro
in excel that would perform this task for me - on loading or saving the
document.

Is this possible, and as I actually does not know any VB or excel macro,
does anyone have an example that I could easily use or extend?

Jan Agermose


--

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
Script to Print Range of Cells Lisa Excel Discussion (Misc queries) 3 January 22nd 09 04:45 PM
How to get in a vbs script the sum of values of a Excel cells in a certain range? Claudia d'Amato Excel Discussion (Misc queries) 2 June 28th 08 12:02 AM
Please help with this... using a marco to modify cells CSUS_CE_Student[_2_] Excel Discussion (Misc queries) 1 June 27th 07 12:40 AM
Script doesn't work when cells are merged. [email protected] Excel Discussion (Misc queries) 2 January 26th 07 07:36 AM
SCRIPT: custom formatting nastech Excel Discussion (Misc queries) 0 April 27th 06 04:54 PM


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