Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Read Multiple excel files and save data in single excel sheet
#4
Solved: 10 Years, 10 Months ago
Hi venkat,

Thanks for your help,

i written a code to read multiple excel sheet and save it properlly, function is

Code:
Function ExcelUtilities( )

Dim oFolder        
Dim aFile        
Dim FSO              
Set oXL = CreateObject("Excel.Application")        
Set objExcel = CreateObject("Excel.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")                
        

oXL.DefaultFilePath = "C:\Results"                
oXL.DisplayAlerts = False        
If FSO.FolderExists(oXL.DefaultFilePath) then            
     Set oFolder = FSO.GetFolder(oXL.DefaultFilePath)                      
     For each aFile in oFolder.Files              
          If Right(LCase(aFile.Name), 4) = ".xls" Then                                      
              
                Set objWorkbook1= objExcel.Workbooks.Open(aFile.Name)
                Set objWorkbook3= objExcel.Workbooks.Open("C:\results.xls")
                rcount=objWorkbook3.Worksheets("Sheet1").UsedRange.rows.count
                rcount=rcount+1
                st="A"&rcount
                objWorkbook1.Worksheets("Results").UsedRange.Copy
                objWorkbook3.Worksheets("Sheet1").Range(st).PasteSpecial Paste =xlValues
                objWorkbook1.save
                objWorkbook3.save
                objWorkbook1.close
                objWorkbook3.close
                
            End If            
    Next      
    Set oFolder = Nothing        
    end if        
    oXL.DisplayAlerts = True        
    oXL.Quit        
    Set     oXL = Nothing

End Function
it works fine,
but when i run next time is there any process to delete all previous data from results.xls and save it once again from row 1. please take in consider

Thanks
Mahesh


Messages In This Thread
RE: How to Read Multiple excel files and save data in single excel sheet - by upadhyay40 - 12-02-2009, 12:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert the single to an integer Mozza 2 1,276 09-27-2018, 12:36 PM
Last Post: Ankur
  Comparing two unsorted excel columns ProTester 2 2,581 09-13-2018, 02:11 PM
Last Post: ProTester
  export UFT datasheet to excel and then append Mozza 0 1,695 09-04-2018, 08:58 AM
Last Post: Mozza
  how can i click a macro button in excel using vbscript arpan 1 3,621 10-03-2017, 06:27 AM
Last Post: supputuri
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,612 01-17-2017, 11:05 AM
Last Post: JACKSPARROW

Forum Jump:


Users browsing this thread: 1 Guest(s)