Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selection.Replace doesn't update the cell value in macro!

Hi everyone,
I'm trying to read a text file containg data like this
5.55
5.57
5.98
5.63
5.82
into Excel 2000, replacing the "." by ",", and calcualting the mean
value in the following macro sequence:

....
Dim theRange As Range

Range("A1:A5").Select
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Set theRange = Selection
Range("B1").Value = Application.WorksheetFunction.Average(theRange)
....

I get the run time error 1004 'Could not find Average property for
Worksheet function class'. The problem is probably that after
selection.replace, the cell values aren't correctly updated. Doing this
manually in the worksheet doesn't cause any problem and runs just fine!!!

Any comments, solutions???

Thanks in advance

/Nasser Hosseini

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Selection.Replace doesn't update the cell value in macro!

How can you average 5,55 and 5,57? Those aren't numbers.
I used your same code to replace the commas with periods
and it worked fine. Sorry for the confusion.

-Brad
-----Original Message-----
Hi everyone,
I'm trying to read a text file containg data like this
5.55
5.57
5.98
5.63
5.82
into Excel 2000, replacing the "." by ",", and

calcualting the mean
value in the following macro sequence:

....
Dim theRange As Range

Range("A1:A5").Select
Selection.Replace What:=".", Replacement:=",",

LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Set theRange = Selection
Range("B1").Value = Application.WorksheetFunction.Average

(theRange)
....

I get the run time error 1004 'Could not find Average

property for
Worksheet function class'. The problem is probably that

after
selection.replace, the cell values aren't correctly

updated. Doing this
manually in the worksheet doesn't cause any problem and

runs just fine!!!

Any comments, solutions???

Thanks in advance

/Nasser Hosseini

.

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
Using a cell reference within a macro to find and replace McCloudK Excel Discussion (Misc queries) 1 September 17th 07 07:04 PM
Line selection from a cell script through a VBA macro CamiIRE Setting up and Configuration of Excel 2 April 11th 06 04:28 PM
Macro - Dynamic cell selection Chris Excel Discussion (Misc queries) 1 January 11th 06 01:48 PM
Macro for cell selection starting with Last Cell Valerie Excel Worksheet Functions 4 December 9th 05 08:25 PM
Macro for selecting entire row from mouse cell selection PaiolaS Excel Programming 1 August 7th 03 07:01 PM


All times are GMT +1. The time now is 11:58 PM.

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"