Excel Pastespecial Cell using OLE
Keywords: Excel Paste Special Cell OLE pastespecial
Question:
Can someone give me an example of performing a copy and pastespecial for values from one cell to another using OLE objects? I'm trying to copy the value from a cell with a function to another cell. Thanks.Answer:
Try this puppy, it starts excel opens a blank workbook and puts values in the first column, then copies them over to the 3rd column...1 and 3 work ok, but the =NOW() function looks a little funky. You might try recording a new macro copy/paste special by hand, then go in and edit the macro and see what VBA has to say...
; Start excel here excelxls = objectopen("Excel.Application") excelxls.visible = @true rptxls = excelxls.workbooks rptxls.add actSheet = excelxls.activesheet xlsvalues = "77;=now();=11+22+33" for y = 1 to 3 val = itemextract(y, xlsvalues, ";") cells = actSheet.cells(y, 1) cells.value = val next xlFormulas = -4123 for y = 1 to 3 cells = actSheet.cells(y, 1) cells.copy newcell = actSheet.cells(y, 3) newcell.PasteSpecial(::Paste=xlFormulas) next exit
Article ID: W14692Filename: Excel Paste Special.txt