Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Returning a value, not a formula


Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2006, 12:21 PM
zx12r zx12r is offline
Newcomer
 
Join Date: Mar 2006
Posts: 5
Default Returning a value, not a formula


Hey all, I need a little help with something pretty basic. I have a macro that performs a simple calculation. How do I return only the result, the integer information, to the cell without the formula tracking along with it?

ActiveCell.FormulaR1C1 = "=R[-1]C+1"

Thanks for any help on this!
Reply With Quote
  #2  
Old 04-11-2006, 12:25 PM
zx12r zx12r is offline
Newcomer
 
Join Date: Mar 2006
Posts: 5
Default

I've been trying something like this...

Dim z As Integer

Set z = ActiveCell.FormulaR1C1 = "=R[-1]C+1"
ActiveCell.Value = z

But calling out a formula in a variable definition seems to be a problem...

Thanks again....
Reply With Quote
  #3  
Old 04-11-2006, 01:02 PM
rick_deacha's Avatar
rick_deacha rick_deacha is offline
Sith Lord

Retired Leader
* Expert *
 
Join Date: Feb 2004
Location: Monterrey, Mexico
Posts: 2,179
Default

Code:
Dim z As Integer z = Activecell.offset(-1,0).value + 1 ActiveCell.Value = z
Should do the trick, or just
Code:
ActiveCell.Value = Activecell.offset(-1,0).value + 1
__________________
Rick
Use [vb][/vb] | Refer to VBA or VB | Newbie? run the Macro Recorder
Excel and VB Automation :|: Excel FAQ
Reply With Quote
  #4  
Old 04-11-2006, 02:22 PM
zx12r zx12r is offline
Newcomer
 
Join Date: Mar 2006
Posts: 5
Thumbs up

Perfect! Thanks!
Reply With Quote
Reply


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
 
 
-->