LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Help with VBA runtime error

I get runtime error - 1004 Method 'Range' of object _Worksheet
failed during the Set sRange line. I even tried to hard code row/col
values (next commented line) and get the same error. Please advise.
Thanks!

' Get the info for the RESULTNAME block from ONE
' of the sheets; I'll be copying 4 sets of row:col
' data so I defined the rowArray(4) and colArray(4)
Sub getResultInfo()
Dim baseBook As Workbook
Dim sheet1 As Worksheet ' destination
Dim sheet2 As Worksheet ' source
Dim sRange As Range ' source
Dim dRange As Range ' dest
Dim colVals(4) ' column numbers to be copied
Dim destRow As Integer
Dim destCol As Integer
Const srcRow = 99 ' row number to be copied

' Brute force assignment of columns to
' be copied
colVals(1) = 2
colVals(2) = 5
colVals(3) = 11
colVals(4) = 12

destRow = resRow + 1 ' resRow obtained in writeHeaders1()
destCol = resCol + 1
Application.ScreenUpdating = False
Set baseBook = ThisWorkbook
Set sheet1 = baseBook.Sheets(1)
Set sheet2 = baseBook.Sheets(2)

'Copy RESULTNAME
Set sRange = sheet2.Range(Cells(srcRow, colVals(1)), _
Cells((srcRow + 16), colVals(1)))
' Set sRange = sheet2.Range(Cells(99, 2), Cells(114, 2))

Set dRange = sheet1.Range(Cells(destRow, destCol), _
Cells(destRow, (destCol + 16)))
Call copyRange(sRange, dRange)
End Sub
 
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
xpath error? Runtime Error 13 type mismatch Steve M[_2_] Excel Discussion (Misc queries) 0 January 17th 08 01:16 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 07:14 PM.

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"