Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default etract unique data from multiple workbooks after extracting data

hi,
I have a some of workbooks in a folder, which I created using a
macro (from text files). The coulmns and data types are the same
across these workbooks. Column C has a 15 digit number, I need to
extract the first 2 digits from the column and insert it in another
column (new column). Once this is done on all the workbooks I need to
extract unique data from all the workbooks and paste it in the current
workbook from which I'm running the macro. I need to get this done
through a macro as I connot combine the data (their are more than 100K
of rows in all the files). For example
Workbook1
Column C Extracted data
123456789012345 12
234567890112345 23
123456789012345 12
321456712389034 32
342445432321321 34

Workbook2
Column C Extracted data
123456789012345 12
134567890112345 13
143456789012345 14
321456712389034 32
342445432321321 34

From the above 2 workbooks I need to get the unique values, so it
would be 12, 13,14,23,32,34.

Could anyone please help me with this. Thanks in advance for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default etract unique data from multiple workbooks after extracting data

Try this code

Sub GetData()

Const Folder = "c:\temp\working"

With ThisWorkbook.ActiveSheet
If .Range("C1") = "" Then
NewRow = 1
Else
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
End If
End With
First = True
Do
If First = True Then
Filename = Dir(Folder & "\*.xls")
First = False
Else
Filename = Dir()
End If

If Filename < "" Then
Workbooks.Open Filename:=Folder & _
"\" & Filename
With ActiveWorkbook.ActiveSheet

RowCount = 1
Do While .Range("C" & RowCount) < ""
ExtractData = Left(.Range("C" & RowCount), 2)
.Range("D" & RowCount) = ExtractData

With ThisWorkbook.ActiveSheet
Set c = .Columns("C:C").Find( _
what:=ExtractData, _
LookIn:=xlValues)
If c Is Nothing Then
.Range("C" & NewRow) = ExtractData
NewRow = NewRow + 1
End If
End With
RowCount = RowCount + 1
Loop
ActiveWorkbook.Close SaveChanges:=True
End With
End If
Loop While Filename < ""

End Sub

" wrote:

hi,
I have a some of workbooks in a folder, which I created using a
macro (from text files). The coulmns and data types are the same
across these workbooks. Column C has a 15 digit number, I need to
extract the first 2 digits from the column and insert it in another
column (new column). Once this is done on all the workbooks I need to
extract unique data from all the workbooks and paste it in the current
workbook from which I'm running the macro. I need to get this done
through a macro as I connot combine the data (their are more than 100K
of rows in all the files). For example
Workbook1
Column C Extracted data
123456789012345 12
234567890112345 23
123456789012345 12
321456712389034 32
342445432321321 34

Workbook2
Column C Extracted data
123456789012345 12
134567890112345 13
143456789012345 14
321456712389034 32
342445432321321 34

From the above 2 workbooks I need to get the unique values, so it
would be 12, 13,14,23,32,34.

Could anyone please help me with this. Thanks in advance for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default etract unique data from multiple workbooks after extracting data

Thank you so much..... it worked..... I modified it a little bit.
Thanks again
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default etract unique data from multiple workbooks after extracting data

On Dec 26, 2:44*am, Joel wrote:
Try this code

Sub GetData()

Const Folder = "c:\temp\working"

With ThisWorkbook.ActiveSheet
* *If .Range("C1") = "" Then
* * * NewRow = 1
* *Else
* * * LastRow = .Range("C" & Rows.Count).End(xlUp).Row
* * * NewRow = LastRow + 1
* *End If
End With
First = True
Do
* *If First = True Then
* * * Filename = Dir(Folder & "\*.xls")
* * * First = False
* *Else
* * * Filename = Dir()
* *End If

* *If Filename < "" Then
* * * Workbooks.Open Filename:=Folder & _
* * * * *"\" & Filename
* * * With ActiveWorkbook.ActiveSheet

* * * * *RowCount = 1
* * * * *Do While .Range("C" & RowCount) < ""
* * * * * * ExtractData = Left(.Range("C" & RowCount), 2)
* * * * * * .Range("D" & RowCount) = ExtractData

* * * * * * With ThisWorkbook.ActiveSheet
* * * * * * * *Set c = .Columns("C:C").Find( _
* * * * * * * * * what:=ExtractData, _
* * * * * * * * * LookIn:=xlValues)
* * * * * * * *If c Is Nothing Then
* * * * * * * * * .Range("C" & NewRow) = ExtractData
* * * * * * * * * NewRow = NewRow + 1
* * * * * * * *End If
* * * * * * End With
* * * * * * RowCount = RowCount + 1
* * * * *Loop
* * * * *ActiveWorkbook.Close SaveChanges:=True
* * * End With
* *End If
Loop While Filename < ""

End Sub



" wrote:
hi,
* I have a some of workbooks in a folder, which I created using a
macro (from text files). The coulmns and data types are the same
across these workbooks. Column C has a 15 digit number, I need to
extract the first 2 digits from the column and insert it in another
column (new column). Once this is done on all the workbooks I need to
extract unique data from all the workbooks and paste it in the current
workbook from which I'm running the macro. I need to get this done
through a macro as I connot combine the data (their are more than 100K
of rows in all the files). For example
Workbook1
Column C * * * * * * * * * * *Extracted data
123456789012345 * * * * * 12
234567890112345 * * * * * *23
123456789012345 * * * * * *12
321456712389034 * * * * * *32
342445432321321 * * * * * *34


Workbook2
Column C * * * * * * * * * * *Extracted data
123456789012345 * * * * * 12
134567890112345 * * * * * *13
143456789012345 * * * * * *14
321456712389034 * * * * * *32
342445432321321 * * * * * *34


From the above 2 workbooks I need to get the unique values, so it
would be 12, 13,14,23,32,34.


Could anyone please help me with this. Thanks in advance for any help.- Hide quoted text -


- Show quoted text -



hi

I need you guys help. how do I return a column of Fruits to a row with
Unique Fruit using excel formula. Example below



Apple Orange Pear Strawberry
Apple
Apple
Apple
Orange
Orange
Pear
Orange
Pear
Strawberry
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting data from multiple new workbooks via one master workboo iBob Setting up and Configuration of Excel 1 March 2nd 10 08:06 AM
Extracting data from multiple new workbooks via one master workboo iBob Excel Worksheet Functions 1 January 15th 10 04:21 AM
Excel Workbooks, user returns, extract unique data [email protected] Excel Discussion (Misc queries) 2 April 23rd 07 09:36 AM
Extracting Data for .Txt Files By Unique Field Data La Excel Discussion (Misc queries) 3 July 17th 06 01:30 PM
Extracting data from one row across multiple columns Sarah Excel Programming 1 September 7th 04 10:06 AM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"