Need help in vbscript
Posted: Fri Oct 07, 2011 4:03 am
Hello 1)I need vbscript which search for the folder in the directory and opens the files in the folder which has .xls extension.
2) secondly from the workbook , i need to copy only two columns from
sheet1 to sheet2(based on their column header)i.e. if the column header
is "serial number" and "product id" i want to copy these two columns to
the next sheet. 3) Actually I have written a code which finds the
folder and opens the file in the folder and which is working perfect,
but I need the script for copying and pasting the columns. please help
me in doing this. If you could not follow my question please let me
know.Here is my code :
2) secondly from the workbook , i need to copy only two columns from
sheet1 to sheet2(based on their column header)i.e. if the column header
is "serial number" and "product id" i want to copy these two columns to
the next sheet. 3) Actually I have written a code which finds the
folder and opens the file in the folder and which is working perfect,
but I need the script for copying and pasting the columns. please help
me in doing this. If you could not follow my question please let me
know.Here is my code :
Code: Select all
Option Explicit On Error Resume Next Dim oXL Dim oFolder Dim aFile Dim FSO Dim xTc Set oXL = CreateObject("Excel.Application") Set FSO = CreateObject("Scripting.FileSystemObject") oXL.DefaultFilePath = "C:Documents and SettingsNarahariSrMy DocumentsRemoval Reports" oXL.DisplayAlerts = False msgbox (" done") msgbox(oXL.DefaultFilePath) 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 oXL.Workbooks.Open(aFile.Name) msgbox ("in loop") xTc=extract(oXl) oXL.Visible = True End If Next Set oFolder = Nothing end if oXL.DisplayAlerts = True oxl.workbook.close [code] Thanx