Data extract adding header and finding text value

xljdg

New Member
Joined
Aug 24, 2011
Messages
8
Code:
[COLOR=#3e3e3e][FONT=Courier New]Sub Consolidate_Trial()[/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#3e3e3e]Dim wbkDst As Workbook[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Dim wbkSrc As Workbook[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Dim fso, f, fs, f1[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Dim I As Long[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Set fso = CreateObject("Scripting.FileSystemObject")[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Set f = fso.getfolder("C:\Temp")[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Set fs = f.Files[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]For Each f1 In fs[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]For I = 1 To fs.Count[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]If Right(f1.Name, 3) = "xls" Then[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Set wbkSrc = Workbooks.Open("C:\Temp" & "\" & f1.Name)[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Set wbkDst = ThisWorkbook[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]WsDst.Range("A" & I) = WsSrc.Range("E16")[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]WsDst.Range("B" & I) = WsSrc.Range("U17")[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]WsDst.Range("C" & I) = WsSrc.Range("D25")[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]WsDst.Range("D" & I) = f1.Name[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]End If[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Next[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]Next[/COLOR][/FONT]
[FONT=Courier New][COLOR=#3e3e3e]End Sub<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/COLOR][/FONT]
[COLOR=#3e3e3e][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
<o:p></o:p>
Using the above code i have been able to copy from all workbooks into a single workbook. What i am struggling with is to add header line data in the first line of my destination sheet. <o:p></o:p>
Eg. Name Destination Cost <o:p></o:p>
In my source workbook in column B there is a code called “FIN009” that is common across all workbooks. I need to search for it and if found then in my destination sheet i need to say complete if not found say incomplete using the above wstDst.Range(“E” &I) = “complete” or incomplete<o:p></o:p>
Can someone give me some pointers. I have cross posted this at OZGRID as well but have had not solutions. Appreciate your time and patience with this post.<o:p></o:p>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top