Micro Focus QTP (UFT) Forums
Paste a Range from Excel to Excel - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Paste a Range from Excel to Excel (/Thread-Paste-a-Range-from-Excel-to-Excel)



Paste a Range from Excel to Excel - Brian3 - 10-27-2008

Hey guys,

Im need to copy a range of values in excel (say A1 - F5), and paste this range into another excel sheet. the reason for this is that im gathering alot of information form multiple excel sheets and putting it into one central sheet to call at runtime. So far ive written this but its just pasting blank into my sheet -

Code:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\sheet1.xls")
      objExcel.Visible = True

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook2 = objExcel.Workbooks.Open("C:\sheet2.xls")
      objExcel.Visible = True

      Set objRange = objExcel.Range("F10","J35")
      objRange.copy
      objExcel.Range("F10","J35") = objRange
      objExcel.Quit


Can anyone see where im going wrong? any help would be greatly appreciated.

Thanks,
Brian