Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Script to Print Range of Cells | Excel Discussion (Misc queries) | |||
How to get in a vbs script the sum of values of a Excel cells in a certain range? | Excel Discussion (Misc queries) | |||
Please help with this... using a marco to modify cells | Excel Discussion (Misc queries) | |||
Script doesn't work when cells are merged. | Excel Discussion (Misc queries) | |||
SCRIPT: custom formatting | Excel Discussion (Misc queries) |