Z
Zilla
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
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