cancel
Showing results for 
Search instead for 
Did you mean: 

RunTime error with AO Crosstab Range with Protected sheet

sravantis
Discoverer
0 Kudos

Hello Team,

I have followed the following link to get the range of crosstab to use in formulas.

https://archive.sap.com/discussions/thread/3571943#

In code i used... cells(1,2) or range("B1") to write the result of ifirstrow, ilastrow etc to my excel. Its works wonderfully, gives results as expected when the sheet is not protected. However, When the sheet is protected, it gives Run time: 1004 error at the "cells(1,2) = ifirstrow " line. However, when i use code like "MsgBox ifirstrow" the doesn't throw error.

Please suggest, how to work it out.

Code is as below:

ifirstrow = Range("SAPCrosstab1").Row
MsgBox ifirstrow ' Works with protected sheet
'Range("B6").value = ifirstrow
'Cells(1, 2) = ifirstrow

ilastrow = Range("SAPCrosstab1").Rows.Count + ifirstrow - 1
Cells(2, 2) = ilastrow ' gives runtime error : 1004, on protected sheet
iFirstColumn = Range("SAPCrosstab1").Column
Cells(3, 2) = iFirstColumn
iLastColumn = Range("SAPCrosstab1").Columns.Count + iFirstColumn - 1
Cells(4, 2) = iLastColumn

Regards,

Accepted Solutions (0)

Answers (0)