Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Returning value of a cell containing a formula

This question shows how little I know of Excel.
I'm involved in a VB application running Excel in background
(Visible=false).
All I need to do is read and write values to certain cells.
No problem reading when the cell has a value, but when the cell has a
formula, I get a Type Mismatch error.
I moved a snip of my VB code into Excel VBA and get the same result when
running natively in Excel.

Here is my simple attempt:

Dim myRange As Range
Set myRange = Worksheets("HP - GST Sched").Cells(3, 5)
MsgBox myRange

Any help much appreciated

Ian B


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Returning value of a cell containing a formula

Ian,

The only way I could get a type mismatch error is if the result
of the formula is an error value like #VALUE or #DIV/0. To cope
with this situation, use IsError to test the cell value prior to
using it in the MsgBox. For example,

Dim myRange As Range
Set myRange = Worksheets(1).Cells(3, 5)
If IsError(myRange.Value) Then
MsgBox "Cell contains an error value."
Else
MsgBox myRange
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ian Bayly" wrote in message
...
This question shows how little I know of Excel.
I'm involved in a VB application running Excel in background
(Visible=false).
All I need to do is read and write values to certain cells.
No problem reading when the cell has a value, but when the cell

has a
formula, I get a Type Mismatch error.
I moved a snip of my VB code into Excel VBA and get the same

result when
running natively in Excel.

Here is my simple attempt:

Dim myRange As Range
Set myRange = Worksheets("HP - GST Sched").Cells(3, 5)
MsgBox myRange

Any help much appreciated

Ian B




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need formula returning a blank cell vdmbqb Excel Discussion (Misc queries) 4 November 28th 09 04:51 PM
VLookup returning #N/A when looking up a cell that has a Formula i mickn74 Excel Discussion (Misc queries) 3 July 28th 09 08:14 AM
Returning a cell's formula in a different cell T.R. Young Excel Worksheet Functions 2 February 16th 06 06:41 PM
Returning the formula in another cell gelert Excel Worksheet Functions 2 September 6th 05 01:48 AM
Returning the formula in a cell Sukhjeet Excel Discussion (Misc queries) 0 June 29th 05 11:24 AM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"