excel - How to copy values only using Sheets(Array()).Copy -


i have following code copies worksheets new workbook. copies sheets formulae etc. after loop though each worksheet in resultant workbook copy , paste values. there way create worksheets values first time round?

sheets(array("eq spot moves valuation", _                  "zari swap prll", _                  "zari bond prll", _                  "zar swap pdh", _                  "zar bond pdh", _                  "grid report eq", _                  "valuations", _                  "zar bond prll pdh", _                  "grid report fx")).copy   ' ...snip    each ws in exposureoutputwb.sheets    ' copy , past values on each sheet    next ws       

there difference copy method if applied worksheets or ranges. ranges can use pastespecial [format] later on, must copy ranges beginning, in

sub copyallasvalues() dim wo workbook, worksheet           ' old dim wn workbook, sn worksheet           ' new      set wo = activeworkbook                   ' come     set wn = workbooks.add                    ' new sheet values      each in wo.worksheets         set sn = wn.worksheets.add            ' create new sheet         sn.name = so.name                     ' copy name         so.cells.copy                         ' copy cells clipboard         sn.[a1].pastespecial xlpastevalues    ' paste values @ a1         sn.[a1].pastespecial xlpasteformats   ' paste formats @ a1     next end sub 

this code should illustrate principle, doesn't care correct positioning of sheets (use before or after parameters on worksheets.add)and not duplicate sheet names may occur if 1 of original sheet names match default names in newly created workbook on system (usually sheet1 .. sheet3)

hope helps

good luck


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

c# - Getting "Internal .Net Framework Data Provider error 30" error when column has NULL value -

c++ - How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu? -