Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default use formula on external data range

Hi All,
I've got a problem with data I read from a database.

I wrote a VBA Sub in Excel 2007 with retrieves data via
ActiveSheet.QueryTables.Add() per OLEDB out of a database.

This works fine and puts the data in the range beginning on cell "A8"

Now my problem:
I have a formula '=SUM(A8:A10) in cell "B1".
This formula always comes out = 0, although there are values in the cells.

But if I edit cell "A8" without changing the value (just the alignment
changes) it is recognized and the formula shows = 1

What am I missing here ?

Thanks for any help,
Ralf.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default use formula on external data range

Your problem is that the data retrieved is being treated as text rather than
a number. You can simulate this by putting '1 in some cell, copying the
cell, and paste/special/value into A1.

A1 will APPEAR to have a value, but its really only Text, that is
=SUM(A1:A1) will display 0


To fix this in VBA, something like:

Sub convertt()
Range("A1").Value = Range("A1").Value
End Sub

--
Gary''s Student - gsnu201002


"IronKalli" wrote:

Hi All,
I've got a problem with data I read from a database.

I wrote a VBA Sub in Excel 2007 with retrieves data via
ActiveSheet.QueryTables.Add() per OLEDB out of a database.

This works fine and puts the data in the range beginning on cell "A8"

Now my problem:
I have a formula '=SUM(A8:A10) in cell "B1".
This formula always comes out = 0, although there are values in the cells.

But if I edit cell "A8" without changing the value (just the alignment
changes) it is recognized and the formula shows = 1

What am I missing here ?

Thanks for any help,
Ralf.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default use formula on external data range

Hello,
thanks for your answer. It helps.

But do you know of a way to 'convince' VBA to directly insert
the data formatted to number or general and not as text ?

Kind regards,
Ralf
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default use formula on external data range

Hello,
thanks for your answer. It helps.

But do you know of a way to 'convince' VBA to directly insert
the data formatted to number or general and not as text ?

Kind regards,
Ralf
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
External data range FP Novice Excel Discussion (Misc queries) 1 January 23rd 09 04:59 PM
External Data Queries - Data Range Properties v Spreadsheet Format HLS Excel Discussion (Misc queries) 0 April 5th 06 11:09 AM
insert entire row for new data, external data range doesnt work orlya1 Excel Programming 3 April 3rd 06 08:39 PM
How can I check if data in an external data range is changed afte. Ruud Excel Worksheet Functions 0 January 7th 05 12:15 PM
External data range Terry Excel Programming 0 September 18th 04 01:12 PM


All times are GMT +1. The time now is 02:07 AM.

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

About Us

"It's about Microsoft Excel"