View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
purpleding purpleding is offline
external usenet poster
 
Posts: 1
Default Copy method of worksheet class failed - help!


Help! I got the same error using Excel 2003

Here is my code, and I got this error after it copies 63 times.
It will copy about 110 times.

Please help

sub populateworksheet()
dim totalrow, isheet, rownum, v_col, icol as integer
dim mysht, metadata as worksheet
dim sheetname as string
dim fnd as range
dim v_cell_value as variant

totalrow =
activeworkbook.worksheets(\"tablename\").usedrange .rows.count

for isheet = 1 to totalrow
worksheets(\"template\").copy after:=worksheets(worksheets.count)
set mysht = worksheets(worksheets.count)
sheetname = activeworkbook.worksheets(\"tablename\").cells(ish eet,
1).value
mysht.name = sheetname
mysht.cells(1, 1).value = sheetname
set metadata = worksheets(\"list\")
set fnd = metadata.columns(1l).find(sheetname, lookat:=xlwhole)
rownum = fnd.row
v_col = 5
icol = 1
do while metadata.cells(rownum, v_col).value < \"\"
v_cell_value = metadata.cells(rownum, v_col).value
mysht.cells(2, icol).value = v_cell_value
v_col = v_col + 1
icol = icol + 1
loop
next isheet

end sub


--
purpleding
------------------------------------------------------------------------
purpleding's Profile: http://www.excelforum.com/member.php...o&userid=30580
View this thread: http://www.excelforum.com/showthread...hreadid=499532