C
cellBert
Setting a range formula that contains date arithmetic destroys formatting:
1.Insert an OWC spreadsheet control and a button onto a VB 6 project.
2.Set cell A1: 11
3.Set cell B1: 1/1/2006
4.Set cell C1: 1/1/2005
5.Set cell D1: =B1-C1
6. Cell D1 will have correct result of 365, but you will have to format cell
to "General"
7. Write this code to respond to the button-click:
Private Sub Command1_Click()
Dim v
v = Form1.Spreadsheet1.Range("a1:d1").Formula
v(1, 1) = 12
Form1.Spreadsheet1.Range("a1:d1").Formula = v
End Sub
8. Run the project and click the button - the cell you just formatted will
change formatting back to a date format, causing the value in D1 to be wrong.
Real Excel doesn't do this.
Is there an easy workaround? Can there be a fix? Thanks.
1.Insert an OWC spreadsheet control and a button onto a VB 6 project.
2.Set cell A1: 11
3.Set cell B1: 1/1/2006
4.Set cell C1: 1/1/2005
5.Set cell D1: =B1-C1
6. Cell D1 will have correct result of 365, but you will have to format cell
to "General"
7. Write this code to respond to the button-click:
Private Sub Command1_Click()
Dim v
v = Form1.Spreadsheet1.Range("a1:d1").Formula
v(1, 1) = 12
Form1.Spreadsheet1.Range("a1:d1").Formula = v
End Sub
8. Run the project and click the button - the cell you just formatted will
change formatting back to a date format, causing the value in D1 to be wrong.
Real Excel doesn't do this.
Is there an easy workaround? Can there be a fix? Thanks.