Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Nested Loop Offset Glitch - Object required (Error 424)

Hello

When I get to
ther.Offset(bb - 1, 0).Value = varA * 5
Object required (Error 424) generates.
What am I doing wrong to alter a cells content in sheet2 from a value in
sheet1*5?


Sub Rand1()
Dim myRange As Range
Dim ro As Integer
Dim co As Integer
Dim aa, bb As Integer
Dim varA As String

' Application.ScreenUpdating = False
Set myRange = Worksheets("Sheet1") _
.Range("A1").CurrentRegion
ro = myRange.Rows.Count
co = myRange.Columns.Count
ther = Worksheets("Sheet2").Range("F2").Address
For aa = 2 To ro
varA = Worksheets("Sheet1").Cells(aa, 6).Value
' MsgBox "Row " & aa & " # " & varA
For bb = 2 To 11

ther.Offset(bb - 1, 0).Value = varA * 5 Runtime Error 424

Next bb
Next aa
' Application.ScreenUpdating = True
End Sub

Appreciatively,
Arturo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Nested Loop Offset Glitch - Object required (Error 424)

You set the implicit variant variable "ther" to a string in

ther = Worksheets("Sheet2").Range("F2").Address

(That's one of the problems with not using Option Explicit at the top of
your module - any variables you don't declare are implicitly declared as
variants, so you won't get a type mismatch when you try to use it
improperly.)


Instead include

Dim ther as Range

and use

Set ther = Worksheets("Sheet2").Range("F2")


In article ,
Arturo wrote:

Hello

When I get to
ther.Offset(bb - 1, 0).Value = varA * 5
Object required (Error 424) generates.
What am I doing wrong to alter a cells content in sheet2 from a value in
sheet1*5?


Sub Rand1()
Dim myRange As Range
Dim ro As Integer
Dim co As Integer
Dim aa, bb As Integer
Dim varA As String

' Application.ScreenUpdating = False
Set myRange = Worksheets("Sheet1") _
.Range("A1").CurrentRegion
ro = myRange.Rows.Count
co = myRange.Columns.Count
ther = Worksheets("Sheet2").Range("F2").Address
For aa = 2 To ro
varA = Worksheets("Sheet1").Cells(aa, 6).Value
' MsgBox "Row " & aa & " # " & varA
For bb = 2 To 11

ther.Offset(bb - 1, 0).Value = varA * 5 Runtime Error 424

Next bb
Next aa
' Application.ScreenUpdating = True
End Sub

Appreciatively,
Arturo

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
424 Object required error J_J Excel Programming 4 November 7th 04 05:34 AM
Object Required Error Steph[_3_] Excel Programming 3 August 13th 04 03:26 PM
object required error message goss[_10_] Excel Programming 6 January 23rd 04 10:22 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
error 424 - Object Required blb Excel Programming 0 October 1st 03 05:32 PM


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