Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Run-time error '424': Object Required

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error '424': Object Required

You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Run-time error '424': Object Required

Hey Thanks jim.

That worked great, but my first sub isn't working either. Let me know
if you see the problem. Thanks again.

Sub getFixedAssets()

Application.Calculation = xlCalculationManual
Dim m As Variant
Dim rglast As Variant
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
cn.Open connString

Dim AssetData As ADODB.Recordset
Set AssetData = New ADODB.Recordset
Dim AssetQuery As String

AssetQuery = "SELECT FourDot, ProjectName, Mid(Acct,1,2) as [Type],
NULL, desc, [acq date], lifemonths, cost, nbv, dep from [FixedAssets1]
" & _
" WHERE FourDot like '" & Sheet20.Range("A1") & "%' order by
FourDot, acct;"
AssetData.Open AssetQuery, cn, adOpenForwardOnly, adLockReadOnly


Dim startRange As Range
Set startRange = Sheet20.Range("A5")

Dim i As Integer

i = 0
Dim r As ADODB.Record


If Not AssetData.EOF Then
'For Each r In AssetData
AssetData.MoveFirst

Do While Not AssetData.EOF

For m = 0 To 9
startRange.Offset(i, m).Value = AssetData.Fields(m).Value
'
Next m

startRange.Offset(i + 1, 0).EntireRow.Insert

i = i + 1
AssetData.MoveNext
Loop
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.CopyFixedAssetsformulas
Else
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.SetZero
End If
FixedAssets.CopyFixedAssetsformulas
'FixedAssets.HighlightStartEndIssues

Application.Calculation = xlCalculationAutomatic
End Sub

Jim Thomlinson wrote:
You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error '424': Object Required

Can you narrow it down a bit. What part is not working. Does your open
statement (AssetData.Open) return a valid recordset, ...
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Hey Thanks jim.

That worked great, but my first sub isn't working either. Let me know
if you see the problem. Thanks again.

Sub getFixedAssets()

Application.Calculation = xlCalculationManual
Dim m As Variant
Dim rglast As Variant
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
cn.Open connString

Dim AssetData As ADODB.Recordset
Set AssetData = New ADODB.Recordset
Dim AssetQuery As String

AssetQuery = "SELECT FourDot, ProjectName, Mid(Acct,1,2) as [Type],
NULL, desc, [acq date], lifemonths, cost, nbv, dep from [FixedAssets1]
" & _
" WHERE FourDot like '" & Sheet20.Range("A1") & "%' order by
FourDot, acct;"
AssetData.Open AssetQuery, cn, adOpenForwardOnly, adLockReadOnly


Dim startRange As Range
Set startRange = Sheet20.Range("A5")

Dim i As Integer

i = 0
Dim r As ADODB.Record


If Not AssetData.EOF Then
'For Each r In AssetData
AssetData.MoveFirst

Do While Not AssetData.EOF

For m = 0 To 9
startRange.Offset(i, m).Value = AssetData.Fields(m).Value
'
Next m

startRange.Offset(i + 1, 0).EntireRow.Insert

i = i + 1
AssetData.MoveNext
Loop
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.CopyFixedAssetsformulas
Else
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.SetZero
End If
FixedAssets.CopyFixedAssetsformulas
'FixedAssets.HighlightStartEndIssues

Application.Calculation = xlCalculationAutomatic
End Sub

Jim Thomlinson wrote:
You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Run-time error '424': Object Required

Sorry about that................5th line in.

Dim cn As New ADODB.Connection
Says it's an undefined user type. Don't know how to define it, I'm a
newbie to VBA, but I know this works.............it is someone else's
code but it works in another excel file doing the same thing. All I did
was chage the DB and table from which it is retrieving the data.

Jim Thomlinson wrote:
Can you narrow it down a bit. What part is not working. Does your open
statement (AssetData.Open) return a valid recordset, ...
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Hey Thanks jim.

That worked great, but my first sub isn't working either. Let me know
if you see the problem. Thanks again.

Sub getFixedAssets()

Application.Calculation = xlCalculationManual
Dim m As Variant
Dim rglast As Variant
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
cn.Open connString

Dim AssetData As ADODB.Recordset
Set AssetData = New ADODB.Recordset
Dim AssetQuery As String

AssetQuery = "SELECT FourDot, ProjectName, Mid(Acct,1,2) as [Type],
NULL, desc, [acq date], lifemonths, cost, nbv, dep from [FixedAssets1]
" & _
" WHERE FourDot like '" & Sheet20.Range("A1") & "%' order by
FourDot, acct;"
AssetData.Open AssetQuery, cn, adOpenForwardOnly, adLockReadOnly


Dim startRange As Range
Set startRange = Sheet20.Range("A5")

Dim i As Integer

i = 0
Dim r As ADODB.Record


If Not AssetData.EOF Then
'For Each r In AssetData
AssetData.MoveFirst

Do While Not AssetData.EOF

For m = 0 To 9
startRange.Offset(i, m).Value = AssetData.Fields(m).Value
'
Next m

startRange.Offset(i + 1, 0).EntireRow.Insert

i = i + 1
AssetData.MoveNext
Loop
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.CopyFixedAssetsformulas
Else
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.SetZero
End If
FixedAssets.CopyFixedAssetsformulas
'FixedAssets.HighlightStartEndIssues

Application.Calculation = xlCalculationAutomatic
End Sub

Jim Thomlinson wrote:
You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Run-time error '424': Object Required

You have other replies at your other posts.

"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)

Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)

Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False

Sheet20.Range("A5").Select

End Sub


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error '424': Object Required

You require a reference to the ADODB library. In the VBE select Tools -
References - ActiveX Data objects Library 2.? Note that if you deploy this
to someone who does not have this library the code will crash. You are best
off in that case to select a low version number for the best chances of them
having the reference or using late binding but taht is a diferent discussion
all together.
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Sorry about that................5th line in.

Dim cn As New ADODB.Connection
Says it's an undefined user type. Don't know how to define it, I'm a
newbie to VBA, but I know this works.............it is someone else's
code but it works in another excel file doing the same thing. All I did
was chage the DB and table from which it is retrieving the data.

Jim Thomlinson wrote:
Can you narrow it down a bit. What part is not working. Does your open
statement (AssetData.Open) return a valid recordset, ...
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Hey Thanks jim.

That worked great, but my first sub isn't working either. Let me know
if you see the problem. Thanks again.

Sub getFixedAssets()

Application.Calculation = xlCalculationManual
Dim m As Variant
Dim rglast As Variant
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
cn.Open connString

Dim AssetData As ADODB.Recordset
Set AssetData = New ADODB.Recordset
Dim AssetQuery As String

AssetQuery = "SELECT FourDot, ProjectName, Mid(Acct,1,2) as [Type],
NULL, desc, [acq date], lifemonths, cost, nbv, dep from [FixedAssets1]
" & _
" WHERE FourDot like '" & Sheet20.Range("A1") & "%' order by
FourDot, acct;"
AssetData.Open AssetQuery, cn, adOpenForwardOnly, adLockReadOnly


Dim startRange As Range
Set startRange = Sheet20.Range("A5")

Dim i As Integer

i = 0
Dim r As ADODB.Record


If Not AssetData.EOF Then
'For Each r In AssetData
AssetData.MoveFirst

Do While Not AssetData.EOF

For m = 0 To 9
startRange.Offset(i, m).Value = AssetData.Fields(m).Value
'
Next m

startRange.Offset(i + 1, 0).EntireRow.Insert

i = i + 1
AssetData.MoveNext
Loop
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.CopyFixedAssetsformulas
Else
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.SetZero
End If
FixedAssets.CopyFixedAssetsformulas
'FixedAssets.HighlightStartEndIssues

Application.Calculation = xlCalculationAutomatic
End Sub

Jim Thomlinson wrote:
You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Run-time error '424': Object Required

Thanks Jim, that worked

Jim Thomlinson wrote:
You require a reference to the ADODB library. In the VBE select Tools -
References - ActiveX Data objects Library 2.? Note that if you deploy this
to someone who does not have this library the code will crash. You are best
off in that case to select a low version number for the best chances of them
having the reference or using late binding but taht is a diferent discussion
all together.
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Sorry about that................5th line in.

Dim cn As New ADODB.Connection
Says it's an undefined user type. Don't know how to define it, I'm a
newbie to VBA, but I know this works.............it is someone else's
code but it works in another excel file doing the same thing. All I did
was chage the DB and table from which it is retrieving the data.

Jim Thomlinson wrote:
Can you narrow it down a bit. What part is not working. Does your open
statement (AssetData.Open) return a valid recordset, ...
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

Hey Thanks jim.

That worked great, but my first sub isn't working either. Let me know
if you see the problem. Thanks again.

Sub getFixedAssets()

Application.Calculation = xlCalculationManual
Dim m As Variant
Dim rglast As Variant
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
cn.Open connString

Dim AssetData As ADODB.Recordset
Set AssetData = New ADODB.Recordset
Dim AssetQuery As String

AssetQuery = "SELECT FourDot, ProjectName, Mid(Acct,1,2) as [Type],
NULL, desc, [acq date], lifemonths, cost, nbv, dep from [FixedAssets1]
" & _
" WHERE FourDot like '" & Sheet20.Range("A1") & "%' order by
FourDot, acct;"
AssetData.Open AssetQuery, cn, adOpenForwardOnly, adLockReadOnly


Dim startRange As Range
Set startRange = Sheet20.Range("A5")

Dim i As Integer

i = 0
Dim r As ADODB.Record


If Not AssetData.EOF Then
'For Each r In AssetData
AssetData.MoveFirst

Do While Not AssetData.EOF

For m = 0 To 9
startRange.Offset(i, m).Value = AssetData.Fields(m).Value
'
Next m

startRange.Offset(i + 1, 0).EntireRow.Insert

i = i + 1
AssetData.MoveNext
Loop
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.CopyFixedAssetsformulas
Else
AssetData.Close
Set AssetData = Nothing
cn.Close
Set cn = Nothing
'FixedAssets.SetZero
End If
FixedAssets.CopyFixedAssetsformulas
'FixedAssets.HighlightStartEndIssues

Application.Calculation = xlCalculationAutomatic
End Sub

Jim Thomlinson wrote:
You never verify if you found Summary or not. Try something more like this...

Sub CopyFixedAssetsformulas()
Dim rngFound As Range

With Sheet20
Set rngFound = .Range(.Range("A5"), .cells(rows.count,
"A").end(xlup)).Find(What:="Summary", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=False)


if rngfound is nothing then
msgbox "No Summary"
else
.Range("K5").Copy
.Range(.range("K6"), .cells(rngfound.row - 2, "K")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
.Range("V5").Copy
.Range(.range("V6"), .cells(rngfound.row - 2, "V")).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


.Range("A5").Select
end if
end with

End Sub

--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

I keep getting the error in the subject line. Can someone please help.
Thank you.

Sub CopyFixedAssetsformulas()
Dim startRange As Range
Dim rglast As Variant
Dim lastrange As Variant
Set startRange = Sheet20.Range("A5")
Set rglast = Sheet20.Range("A5").SpecialCells(xlCellTypeLastCel l)


Set lastrange = Sheet20.Range("A5", "A" &
rglast.Row).Find("Summary", LookIn:=xlValues)


Sheet20.Range("K5", "V5").Copy
Sheet20.Range("K6", "V" & lastrange.Row - 2).PasteSpecial
(xlPasteFormulasAndNumberFormats)
Application.CutCopyMode = False


Sheet20.Range("A5").Select


End Sub







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 '424': Object Required loren.pottinger Excel Discussion (Misc queries) 1 August 28th 06 09:56 PM
Run time error '424' object required Meltad Excel Programming 8 August 10th 06 09:34 AM
Excel 2007 Beta 2 - Macro Run-time error '424' Object required jcm21 Excel Programming 0 June 16th 06 07:17 PM
Run-time error '424': Object required Phil Bewig Excel Programming 3 February 1st 04 08:38 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 07:06 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"