SOLVED
Home

Data Extraction

%3CLINGO-SUB%20id%3D%22lingo-sub-653456%22%20slang%3D%22en-US%22%3EData%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-653456%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22msg-body%20P_wpofO%20iy_A%22%3E%3CDIV%20class%3D%22jb_0%20X_6MGW%20N_6Fd5%22%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%20class%3D%22yiv7790347395yahoo-style-wrap%22%3E%3CDIV%3EHi%2C%3C%2FDIV%3E%3CDIV%3EI%20have%20some%20data%20arranged%20in%20Year%2C%20Month%2C%20Day%20format.%20I%20want%20to%20extract%20the%20common%20numbers%20of%20days%20(respective%20to%20month%20and%20year)%20from%20the%204%20data%20sets.%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EI%20have%20also%20attached%20the%20excel%20file%20to%20review.%3C%2FDIV%3E%3CDIV%3EPlease%20guide%20me%20thanks%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ERegards%3C%2FDIV%3E%3CDIV%3EFarhan%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-653456%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-653654%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-653654%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F350402%22%20target%3D%22_blank%22%3E%40farhansaleem%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%20i%26nbsp%3Bhope%20that%20I%20have%20understood%20the%20task.%20You%20want%20to%20check%20if%20a%20date%20is%20on%20monday%20to%20friday%3F%3C%2FP%3E%3CP%3EI%20write%20an%20userdefined%20function%2C%20see%20attached%20file%2C%20too.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EFunction%20commonDays(strYear%20As%20String%2C%20strMonth%20As%20String%2C%20strDay)%20As%20Boolean%3CBR%20%2F%3EDim%20dteDate%20As%20Date%3CBR%20%2F%3E%3CBR%20%2F%3EdteDate%20%3D%20DateSerial(strYear%2C%20strMonth%2C%20strDay)%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20Application.WorksheetFunction.Weekday(dteDate%2C%20vbMonday)%20%26lt%3B%206%20Then%3CBR%20%2F%3EcommonDays%20%3D%20True%3CBR%20%2F%3E%3CBR%20%2F%3EElse%3CBR%20%2F%3E%3CBR%20%2F%3EcommonDays%20%3D%20False%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Function%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FPRE%3E%3CP%3ERegards%20from%20germany%3C%2FP%3E%3CP%3EBernd%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.vba-Tanker.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewww.vba-Tanker.com%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-654289%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-654289%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Bernd%2C%3C%2FP%3E%3CP%3EThank%20you%20to%20your%20prompt%20response%20to%20my%20request.%20The%20function%20that%20you%20defined%20is%20informative%20but%20actually%20i%20want%20to%20extract%20the%20numbers%20of%20days%20that%20are%20found%20common%20among%20the%20four%20data%20sheets%20in%20excel.%3C%2FP%3E%3CP%3ELikewise%3B%3C%2FP%3E%3CP%3ESheet-1%20contain%20days%2024%2C25%2C26%2C%20for%20April%2C%201979%3C%2FP%3E%3CP%3ESheet-2%20only%20contain%2028th%20day%20of%20April%2C%201979%20while%3B%3C%2FP%3E%3CP%3ESheet-3%20and%204%20does%20not%20contain%20any%20number%20of%20days%20in%20April%2C%201979%20so%20we%20can%20say%20that%20we%20do%20not%20found%20common%20numbers%20of%20days%20in%20April%2C%201979.%3C%2FP%3E%3CP%3EWhereas%3B%3C%2FP%3E%3CP%3ESheet-1%2C2%2C3%20and%204%20all%20contain%20the%20days%20of%2018%2C19%20for%20the%20month%20of%20June%2C%201979%20as%20common%20number%20of%20days.%3C%2FP%3E%3CP%3EThese%20common%20days%20are%20also%20highlighted%20with%20yellow%20color%20in%20the%20attached%20excel%20sheet%2C%20thanks%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EFarhan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-654358%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-654358%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F350402%22%20target%3D%22_blank%22%3E%40farhansaleem%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Farhan%2C%3C%2FP%3E%3CP%3Eok%2C%20let's%20take%20a%20look%20at%20the%20attached%20file.%20These%20days%20who%20are%20common%20in%20every%20sheet%20are%20colored%20green%20in%20column%20A.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESub%20CommonDaysInAllSheets()%3CBR%20%2F%3EDim%20lngCol%20As%20Long%3CBR%20%2F%3EDim%20lngRow%20As%20Long%3CBR%20%2F%3EDim%20lngRowMax%20As%20Long%3CBR%20%2F%3EDim%20rngFind1%20As%20Range%3CBR%20%2F%3EDim%20rngFind2%20As%20Range%3CBR%20%2F%3EDim%20rngFind3%20As%20Range%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20Tabelle1%3CBR%20%2F%3ElngRowMax%20%3D%20.Range(%22A%22%20%26amp%3B%20.Rows.Count).End(xlUp).Row%3CBR%20%2F%3EFor%20lngCol%20%3D%204%20To%2017%20Step%204%3CBR%20%2F%3EFor%20lngRow%20%3D%203%20To%20lngRowMax%3CBR%20%2F%3E.Cells(lngRow%2C%20lngCol).Value%20%3D%20_%3CBR%20%2F%3EDateSerial(.Cells(lngRow%2C%20lngCol%20-%203).Value%2C%20.Cells(lngRow%2C%20lngCol%20-%202).Value%2C%20.Cells(lngRow%2C%20lngCol%20-%201).Value)%3CBR%20%2F%3ENext%20lngRow%3CBR%20%2F%3ENext%20lngCol%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20lngRow%20%3D%203%20To%20lngRowMax%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20rngFind1%20%3D%20.Range(%22H%3AH%22).Find(what%3A%3D.Cells(lngRow%2C%20%22D%22).Value%2C%20lookat%3A%3DxlWhole)%3CBR%20%2F%3EIf%20Not%20rngFind1%20Is%20Nothing%20Then%3CBR%20%2F%3ESet%20rngFind2%20%3D%20.Range(%22L%3AL%22).Find(what%3A%3D.Cells(lngRow%2C%20%22D%22).Value%2C%20lookat%3A%3DxlWhole)%3CBR%20%2F%3EIf%20Not%20rngFind2%20Is%20Nothing%20Then%3CBR%20%2F%3ESet%20rngFind3%20%3D%20.Range(%22P%3AP%22).Find(what%3A%3D.Cells(lngRow%2C%20%22D%22).Value%2C%20lookat%3A%3DxlWhole)%3CBR%20%2F%3EIf%20Not%20rngFind3%20Is%20Nothing%20Then%3CBR%20%2F%3E.Cells(lngRow%2C%20%22D%22).Interior.ColorIndex%20%3D%204%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3ENext%20lngRow%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EBernd%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.vba-tanker.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewww.vba-tanker.com%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-654490%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-654490%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F350402%22%20target%3D%22_blank%22%3E%40farhansaleem%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirstly%2C%20is%20this%20the%20calculation%20you%20have%20in%20mind%3F%3C%2FP%3E%3CP%3EI%20have%20taken%20the%20first%20table%20as%20the%20master%20and%20identified%20the%20records%20that%20appear%20in%20all%20three%20secondary%20tables.%20A%20further%20helper%20field%20is%20used%20to%20identify%20the%20dates%20but%20the%20orange%20cell%20gives%20the%20count%20without%20using%20this%20field.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-654974%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-654974%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Bernd%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20man%20this%20is%20exactly%20i%20want%20to%20extract%20the%20common%20numbers%20of%20days%20from%20multiple%20sheets.%20Thank%20you%20for%20the%20help%20and%20guidance%20on%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFarhan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-654977%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-654977%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Peter%2C%3C%2FP%3E%3CP%3EActually%2C%20i%20have%20to%20apply%20composite%20analysis%20on%20these%20extracted%20number%20of%20common%20days.%20Thank%20you%20for%20the%20help.%3C%2FP%3E%3CP%3EFarhan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-655002%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Extraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-655002%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F350402%22%20target%3D%22_blank%22%3E%40farhansaleem%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20was%20a%20solution%20obtained%20with%20the%20dynamic%20array%20version%20of%20Excel%20to%20produce%20a%20list.%26nbsp%3B%20It%20is%20possible%20to%20do%20it%20in%20standard%20versions%20of%20Excel.%20%26nbsp%3B%20The%20count%20only%20requires%20COUNTIFS%20though.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F347933%22%20target%3D%22_blank%22%3E%40Berndvbatanker%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20sure%20an%20efficient%20VBA%20solution%20is%20available%20for%20this%20class%20of%20problem%20using%20the%20scripting%20dictionary%20to%20identify%20duplicates.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F116446i8CA2BABDFA751068%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.JPG%22%20title%3D%22Capture.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
farhansaleem
New Contributor
Hi,
I have some data arranged in Year, Month, Day format. I want to extract the common numbers of days (respective to month and year) from the 4 data sets. 
I have also attached the excel file to review.
Please guide me thanks
 
Regards
Farhan
7 Replies
Solution

@farhansaleem 

Hi, i hope that I have understood the task. You want to check if a date is on monday to friday?

I write an userdefined function, see attached file, too.

 

Function commonDays(strYear As String, strMonth As String, strDay) As Boolean
Dim dteDate As Date

dteDate = DateSerial(strYear, strMonth, strDay)

If Application.WorksheetFunction.Weekday(dteDate, vbMonday) < 6 Then
commonDays = True

Else

commonDays = False

End If

End Function

Regards from germany

Bernd

www.vba-Tanker.com

 

Hi Bernd,

Thank you to your prompt response to my request. The function that you defined is informative but actually i want to extract the numbers of days that are found common among the four data sheets in excel.

Likewise;

Sheet-1 contain days 24,25,26, for April, 1979

Sheet-2 only contain 28th day of April, 1979 while;

Sheet-3 and 4 does not contain any number of days in April, 1979 so we can say that we do not found common numbers of days in April, 1979.

Whereas;

Sheet-1,2,3 and 4 all contain the days of 18,19 for the month of June, 1979 as common number of days.

These common days are also highlighted with yellow color in the attached excel sheet, thanks

Regards

Farhan

@farhansaleem 

Hi Farhan,

ok, let's take a look at the attached file. These days who are common in every sheet are colored green in column A.

 

Sub CommonDaysInAllSheets()
Dim lngCol As Long
Dim lngRow As Long
Dim lngRowMax As Long
Dim rngFind1 As Range
Dim rngFind2 As Range
Dim rngFind3 As Range

With Tabelle1
lngRowMax = .Range("A" & .Rows.Count).End(xlUp).Row
For lngCol = 4 To 17 Step 4
For lngRow = 3 To lngRowMax
.Cells(lngRow, lngCol).Value = _
DateSerial(.Cells(lngRow, lngCol - 3).Value, .Cells(lngRow, lngCol - 2).Value, .Cells(lngRow, lngCol - 1).Value)
Next lngRow
Next lngCol

For lngRow = 3 To lngRowMax

Set rngFind1 = .Range("H:H").Find(what:=.Cells(lngRow, "D").Value, lookat:=xlWhole)
If Not rngFind1 Is Nothing Then
Set rngFind2 = .Range("L:L").Find(what:=.Cells(lngRow, "D").Value, lookat:=xlWhole)
If Not rngFind2 Is Nothing Then
Set rngFind3 = .Range("P:P").Find(what:=.Cells(lngRow, "D").Value, lookat:=xlWhole)
If Not rngFind3 Is Nothing Then
.Cells(lngRow, "D").Interior.ColorIndex = 4
End If
End If
End If

Next lngRow

End With

End Sub

 

Regards

Bernd

www.vba-tanker.com

@farhansaleem 

Firstly, is this the calculation you have in mind?

I have taken the first table as the master and identified the records that appear in all three secondary tables. A further helper field is used to identify the dates but the orange cell gives the count without using this field.

Hi Bernd,

 

Yes, man this is exactly i want to extract the common numbers of days from multiple sheets. Thank you for the help and guidance on it.

 

Farhan

Hi Peter,

Actually, i have to apply composite analysis on these extracted number of common days. Thank you for the help.

Farhan

@farhansaleem 

This was a solution obtained with the dynamic array version of Excel to produce a list.  It is possible to do it in standard versions of Excel.   The count only requires COUNTIFS though.

@Berndvbatanker 

I am sure an efficient VBA solution is available for this class of problem using the scripting dictionary to identify duplicates.

 

Capture.JPG

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
202 Replies