Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Runtime error 438

Greetings. I came across a site that helps introduce the concept of macros.
There is one example...

Sub Example2()
For x = 1 To 5
Cells(x, 3).Select
Selection.Vaue = x + 1
Next x
End Sub

that is simple enough, but when I try to run it, I get 'Runtime error '438'
Object doesn't support this property or method'. When I hit help, it says
some stuff about a friend procedure being called late bound, and automation
objects. Does anyone know what is happening? Thank you.

Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Runtime error 438

Greetings Greg

It's due to a typo.

Change the line to:

Selection.Value = x+1

Regards,
Per

On 24 Dec., 14:34, Greg Snidow
wrote:
Greetings. *I came across a site that helps introduce the concept of macros. *
There is one example...

Sub Example2()
* * For x = 1 To 5
* * * *Cells(x, 3).Select
* * * *Selection.Vaue = x + 1
* * Next x
End Sub

that is simple enough, but when I try to run it, I get 'Runtime error '438'
Object doesn't support this property or method'. *When I hit help, it says
some stuff about a friend procedure being called late bound, and automation
objects. *Does anyone know what is happening? *Thank you.

Greg


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Runtime error 438

There's a typo in the code:

Selection.Vaue = x + 1
should be:
Selection.Value = x + 1

I'd use:

Option Explicit
Sub Example2()
Dim x As Long
For x = 1 To 5
ActiveSheet.Cells(x, 3).Value = x + 1
Next x
End Sub

"Option Explicit" forces me to declare my variables (x in this example).

I qualified cells(x,3) with activesheet. So I know what sheet is getting the
numbers.

I removed the .select line and just plopped the value directly into the cell.
There are very few things that need to be selected for the code to work.



Greg Snidow wrote:

Greetings. I came across a site that helps introduce the concept of macros.
There is one example...

Sub Example2()
For x = 1 To 5
Cells(x, 3).Select
Selection.Vaue = x + 1
Next x
End Sub

that is simple enough, but when I try to run it, I get 'Runtime error '438'
Object doesn't support this property or method'. When I hit help, it says
some stuff about a friend procedure being called late bound, and automation
objects. Does anyone know what is happening? Thank you.

Greg


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Runtime error 438

Others have shown you code that does not use Select and Selection. Perhaps
this previous posting of mine (a response to another person using
Select/Selection type constructions) will be of some help to you in your
future programming...

Whenever you see code constructed like this...

Range("A1").Select
Selection.<whatever

you can almost always do this instead...

Range("A1").<whatever

In your particular case, you have this...

Range("C2:C8193").Select 'select cells to export
For Each r In Selection.Rows

which, using the above concept, can be reduced to this...

For Each r In Range("C2:C8193").Rows

Notice, all I have done is replace Selection with the range you Select(ed)
in the previous statement and eliminate the process of doing any
Select(ion)s. Stated another way, the Selection produced from
Range(...).Select is a range and, of course, Range(...) is a range... and,
in fact, they are the same range, so it doesn't matter which one you use.
The added benefit of not selecting ranges first is your active cell does not
change.

--
Rick (MVP - Excel)


"Greg Snidow" wrote in message
...
Greetings. I came across a site that helps introduce the concept of
macros.
There is one example...

Sub Example2()
For x = 1 To 5
Cells(x, 3).Select
Selection.Vaue = x + 1
Next x
End Sub

that is simple enough, but when I try to run it, I get 'Runtime error
'438'
Object doesn't support this property or method'. When I hit help, it says
some stuff about a friend procedure being called late bound, and
automation
objects. Does anyone know what is happening? Thank you.

Greg




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
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 10:31 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"