Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell???
Formula appears as text in cell??? Formula appears as text in cell???
Formula appears as text in cell???
Go Back  Xtreme Visual Basic Talk > > > Formula appears as text in cell???


Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2012, 08:37 AM
dotnetme dotnetme is offline
Regular
 
Join Date: May 2007
Location: NJ
Posts: 50
Question Formula appears as text in cell???


I'm inserting data into excel sheets and after i fill each sheet I want to sum a column so select the data and add a formula to a cell. However when the sheet is opened the cell contains the formula as text instead of the sumation value. I tired several ways but here are a few different meathods that both end up with the same undesired result.

Code:
'Meathod 1
oSheet.Range("H2:H" & (dtEntries.Rows.Count + 2).ToString).Select()
oSheet.Range("H" & (dtEntries.Rows.Count + 2).ToString).FormulaR1C1= "=SUM(R[-" & (dtEntries.Rows.Count).ToString & "]C:R[-1]C)"

'Meathod 2
oSheet.Range("H" & (dtEntries.Rows.Count + 2).ToString).Formula = "=SUM(H2:H" & ((dtEntries.Rows.Count + 1).ToString).ToString & ")"

'Meathod 3
oSheet.Range("H" & (dtEntries.Rows.Count + 2).ToString).Activate()
oExcel.ActiveCell.Formula = "=SUM(H2:H" & ((dtEntries.Rows.Count + 1).ToString).ToString & ")"
I'm I missing something or do I need to do something special???

VB 2008 (VS 2008)
Excel 2003
Windows XP SP3

Thanks in advance for and help

dotnetme
Reply With Quote
  #2  
Old 07-02-2012, 11:02 AM
Cerian Knight's Avatar
Cerian KnightFormula appears as text in cell??? Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,191
Default

In the line preceding your .Formula (any syntax), add:
Code:
oSheet.Range("H" & (dtEntries.Rows.Count + 2).ToString).NumberFormat = "General"
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').

Last edited by Cerian Knight; 07-02-2012 at 12:11 PM. Reason: Added missing oSheet. to code
Reply With Quote
  #3  
Old 07-02-2012, 11:47 AM
dotnetme dotnetme is offline
Regular
 
Join Date: May 2007
Location: NJ
Posts: 50
Thumbs up

That Worked!!! I didn't think of that. Thanks for your help!!

dotnetme
Reply With Quote
Reply

Tags
excel 2003, excel formula, visual basic 2008


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell??? Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell??? Formula appears as text in cell???
Formula appears as text in cell???
Formula appears as text in cell???
 
Formula appears as text in cell???
Formula appears as text in cell???
 
-->