formatting cells script/marco

  • Thread starter Thread starter Jan Agermose
  • Start date Start date
J

Jan Agermose

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
 
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?
 
Back
Top