<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-GB</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} table.MsoTableGrid {mso-style-name:"Table Grid"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-priority:59; mso-style-unhide:no; border:solid windowtext 1.0pt; mso-border-alt:solid windowtext .5pt; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-border-insideh:.5pt solid windowtext; mso-border-insidev:.5pt solid windowtext; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} </style> <![endif]--> [FONT="]Dear all,[/FONT]
[FONT="] [/FONT]
[FONT="]I need some help in writing a code for the following:[/FONT]
[FONT="]I have a workbook with 11 worksheets in it. Each worksheet has a unique name (such as 167L, 167S, 170S, 170L, 173S, 173L, 175A, 183S, 183L and etc.). Each of the worksheet is updated daily and I need to extract data from specific columns and according to specific time.[/FONT]
[FONT="] [/FONT]
<tbody>
</tbody> [FONT="] [/FONT]
[FONT="]Basically, the code I have used before I was assisted by the www.mrexcel.com/forum before, however, I need to have it devised in a bit different way (pls visit the www….. for details). The code I need should (a) select values at column “B” (the corresponding values are 04:00, 08:00, 12:00, 16:00, 20:00 and 00:00), copy value in column “G” (0, 0, 0, 0, 0, 0) and sum up with values from column “H”, which before being added should be divided by a factor of “2” (0/2=0, 3/2=1.5, 16/2=8, 7/2=3.5, 12/2=6, 0/2=0). The summed values should be copied and pasted into a separate worksheet and it needs to look like this:[/FONT]
[FONT="] [/FONT]
<tbody>
</tbody> [FONT="]The things get a bit complicated as different worksheet in a workbook have slightly different table compare with the one in above. [/FONT]
<tbody>
</tbody> [FONT="] [/FONT]
[FONT="]So, the final output from two worksheets should look like:[/FONT]
[FONT="] [/FONT]
<tbody>
</tbody> [FONT="] [/FONT]
[FONT="]And finally, to make things more complicated, the monitoring hours vary, like in the table below:[/FONT]
[FONT="] [/FONT]
<tbody>
</tbody> [FONT="] [/FONT]
[FONT="]With this worksheet (175A), my final output should look like this:[/FONT]
<tbody>
</tbody> [FONT="] [/FONT]
[FONT="]Since there are no value at column “H”, divided by a factor of “2” is skipped.[/FONT]
[FONT="] [/FONT]
[FONT="]Here is a code I used before, and it executes part of the required job:[/FONT]
[FONT="] [/FONT]
[FONT="]Dim myrow As Long[/FONT]
[FONT="]Dim wksTo As Worksheet[/FONT]
[FONT="]Dim j, s As Long[/FONT]
[FONT="]Dim lastRow, lastsheet As Long[/FONT]
[FONT="]Dim wks As Worksheet[/FONT]
[FONT="]Dim sn As String[/FONT]
[FONT="] [/FONT]
[FONT="] Sheets(1).Select[/FONT]
[FONT="] Sheets.Add.Name = "wksTo"[/FONT]
[FONT="] lastRow = 2 ' set the first row to use, set to 2 so you can add labels in row 1[/FONT]
[FONT="] lastsheet = Sheets.Count[/FONT]
[FONT="] For s = 2 To lastsheet ' Loop thru sheets[/FONT]
[FONT="] Worksheets(s).Activate[/FONT]
[FONT="] With Worksheets(s) ' sheet(s) changes sheets[/FONT]
[FONT="] On Error Resume Next[/FONT]
[FONT="] myrow = .Columns("A").Find(Date).Row[/FONT]
[FONT="] Application.Goto .Range("A" & myrow), True[/FONT]
[FONT="] End With[/FONT]
[FONT="] [/FONT]
[FONT="] With Worksheets(s)[/FONT]
[FONT="] ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Activate[/FONT]
[FONT="] End With[/FONT]
[FONT="] [/FONT]
[FONT="] With Application.ActiveWindow.ActiveCell[/FONT]
[FONT="] dc = 0[/FONT]
[FONT="] sn = Sheets(s).Name[/FONT]
[FONT="] Worksheets("wksTo").Range("G" & lastRow).Formula = sn[/FONT]
[FONT="] For j = 1 To -10 Step -2[/FONT]
[FONT="] Range(.Cells(j, 6), .Cells(j, 6)).Copy Sheets("wksTo").Cells(lastRow, 8 - dc)[/FONT]
[FONT="] dc = dc + 1[/FONT]
[FONT="] Next j[/FONT]
[FONT="] lastRow = lastRow + 1[/FONT]
[FONT="] End With[/FONT]
[FONT="] Next s[/FONT]
[FONT="] [/FONT]
[FONT="] Dim x As Integer[/FONT]
[FONT="] Worksheets("wksTo").Activate[/FONT]
[FONT="] For x = 1 To Worksheets.Count[/FONT]
[FONT="] Cells(x, 1).Value = Worksheets(x).Name[/FONT]
[FONT="] Next x[/FONT]
Dear all,
I need some help in writing a code for the following:
I have a workbook with 11 worksheets in it. Each worksheet has a unique name (such as 167L, 167S, 170S, 170L, 173S, 173L, 175A, 183S, 183L and etc.). Each of the worksheet is updated daily and I need to extract data from specific columns and according to specific time.
<tbody>
</tbody>
Basically, the code I have used before I was assisted by the www.mrexcel.com/forum before, however, I need to have it devised in a bit different way (pls visit the www….. for details). The code I need should (a) select values at column “B” (the corresponding values are 04:00, 08:00, 12:00, 16:00, 20:00 and 00:00), copy value in column “G” (0, 0, 0, 0, 0, 0) and sum up with values from column “H”, which before being added should be divided by a factor of “2” (0/2=0, 3/2=1.5, 16/2=8, 7/2=3.5, 12/2=6, 0/2=0). The summed values should be copied and pasted into a separate worksheet and it needs to look like this:
<tbody>
</tbody>The things get a bit complicated as different worksheet in a workbook have slightly different table compare with the one in above.
<tbody>
</tbody>
So, the final output from two worksheets should look like:
<tbody>
</tbody>
And finally, to make things more complicated, the monitoring hours vary, like in the table below:
<tbody>
</tbody>
With this worksheet (175A), my final output should look like this:
<tbody>
</tbody>
Since there are no value at column “H”, divided by a factor of “2” is skipped.
Here is a code I used before, and it executes part of the required job:
Dim myrow As Long
Dim wksTo As Worksheet
Dim j, s As Long
Dim lastRow, lastsheet As Long
Dim wks As Worksheet
Dim sn As String
Sheets(1).Select
Sheets.Add.Name = "wksTo"
lastRow = 2 ' set the first row to use, set to 2 so you can add labels in row 1
lastsheet = Sheets.Count
For s = 2 To lastsheet ' Loop thru sheets
Worksheets(s).Activate
With Worksheets(s) ' sheet(s) changes sheets
On Error Resume Next
myrow = .Columns("A").Find(Date).Row
Application.Goto .Range("A" & myrow), True
End With
With Worksheets(s)
ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Activate
End With
With Application.ActiveWindow.ActiveCell
dc = 0
sn = Sheets(s).Name
Worksheets("wksTo").Range("G" & lastRow).Formula = sn
For j = 1 To -10 Step -2
Range(.Cells(j, 6), .Cells(j, 6)).Copy Sheets("wksTo").Cells(lastRow, 8 - dc)
dc = dc + 1
Next j
lastRow = lastRow + 1
End With
Next s
Dim x As Integer
Worksheets("wksTo").Activate
For x = 1 To Worksheets.Count
Cells(x, 1).Value = Worksheets(x).Name
Next x
[FONT="] [/FONT]
[FONT="]I need some help in writing a code for the following:[/FONT]
[FONT="]I have a workbook with 11 worksheets in it. Each worksheet has a unique name (such as 167L, 167S, 170S, 170L, 173S, 173L, 175A, 183S, 183L and etc.). Each of the worksheet is updated daily and I need to extract data from specific columns and according to specific time.[/FONT]
[FONT="] [/FONT]
[FONT="]A[/FONT] | [FONT="]B[/FONT] | [FONT="]C[/FONT] | [FONT="]D[/FONT] | [FONT="]E[/FONT] | [FONT="]F[/FONT] | [FONT="]G[/FONT] | [FONT="]H[/FONT] | [FONT="]I[/FONT] |
[FONT="]173L[/FONT] | ||||||||
[FONT="]DATE[/FONT] | [FONT="]TIME[/FONT] | [FONT="]W[/FONT] | [FONT="]DS[/FONT] | [FONT="]WH[/FONT] | [FONT="]S[/FONT] | [FONT="]WC[/FONT] | [FONT="]E[/FONT] | [FONT="]C[/FONT] |
[FONT="]bars[/FONT] | [FONT="]bars[/FONT] | [FONT="]C0[/FONT] | [FONT="]%[/FONT] | [FONT="]%[/FONT] | [FONT="]%[/FONT] | [FONT="]0/64"[/FONT] | ||
[FONT="]27.10.13[/FONT] | [FONT="]00:00[/FONT] | [FONT="]95[/FONT] | [FONT="]28[/FONT] | [FONT="]18[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]02:00[/FONT] | [FONT="]91[/FONT] | [FONT="]28[/FONT] | [FONT="]18[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]2[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]89[/FONT] | [FONT="]28[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]06:00[/FONT] | [FONT="]93[/FONT] | [FONT="]28[/FONT] | [FONT="]16[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]1[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]08:00[/FONT][FONT="][/FONT] | [FONT="]95[/FONT] | [FONT="]28[/FONT] | [FONT="]16[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]3[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]10:00[/FONT] | [FONT="]90[/FONT] | [FONT="]28[/FONT] | [FONT="]16[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]12[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]12:00[/FONT] | [FONT="]89[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]16[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]14:00[/FONT] | [FONT="]92[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]5[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]16:00[/FONT] | [FONT="]95[/FONT] | [FONT="]28[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]7[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]18:00[/FONT] | [FONT="]92[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]8[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]20:00[/FONT] | [FONT="]93[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]12[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
[FONT="] [/FONT] | [FONT="]22:00[/FONT] | [FONT="]90[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]6[/FONT] | [FONT="]24/64"[/FONT] |
[FONT="]28.10.13[/FONT] | [FONT="]00:00[/FONT][FONT="][/FONT] | [FONT="]98[/FONT] | [FONT="]28[/FONT] | [FONT="]14[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]24/64"[/FONT] |
<tbody>
</tbody>
[FONT="]Basically, the code I have used before I was assisted by the www.mrexcel.com/forum before, however, I need to have it devised in a bit different way (pls visit the www….. for details). The code I need should (a) select values at column “B” (the corresponding values are 04:00, 08:00, 12:00, 16:00, 20:00 and 00:00), copy value in column “G” (0, 0, 0, 0, 0, 0) and sum up with values from column “H”, which before being added should be divided by a factor of “2” (0/2=0, 3/2=1.5, 16/2=8, 7/2=3.5, 12/2=6, 0/2=0). The summed values should be copied and pasted into a separate worksheet and it needs to look like this:[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]08:00[/FONT] | [FONT="]12:00[/FONT] | [FONT="]16:00[/FONT] | [FONT="]20:00[/FONT] | [FONT="]00:00[/FONT] |
[FONT="]173L[/FONT] | [FONT="]0[/FONT] | [FONT="]1.5[/FONT] | [FONT="]8[/FONT] | [FONT="]3.5[/FONT] | [FONT="]6[/FONT] | [FONT="]0[/FONT] |
[FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="] [/FONT] |
<tbody>
</tbody>
[FONT="]A[/FONT] | [FONT="]B[/FONT] | [FONT="]C[/FONT] | [FONT="]D[/FONT] | [FONT="]E[/FONT] | [FONT="]F[/FONT] | [FONT="]G[/FONT] | [FONT="]H[/FONT] | |||
[FONT="]183L[/FONT] | ||||||||||
[FONT="]DATE[/FONT] | [FONT="]TIME[/FONT] | [FONT="]W[/FONT] | [FONT="]DS[/FONT] | [FONT="]WH[/FONT] | [FONT="]S[/FONT] | [FONT="]WC[/FONT] | [FONT="]C[/FONT] | |||
[FONT="]bars[/FONT] | [FONT="]bars[/FONT] | [FONT="]C0[/FONT] | [FONT="]%[/FONT] | [FONT="]%[/FONT] | [FONT="]0/64"[/FONT] | |||||
[FONT="]27.10.13[/FONT] | [FONT="]00:00[/FONT] | [FONT="]30[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]3[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]02:00[/FONT] | [FONT="]34[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]1[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]38[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]1[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]06:00[/FONT] | [FONT="]38[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]2[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]08:00[/FONT][FONT="][/FONT] | [FONT="]37[/FONT] | [FONT="]11.5[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]10:00[/FONT] | [FONT="]36[/FONT] | [FONT="]11.5[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]12:00[/FONT][FONT="][/FONT] | [FONT="]31[/FONT] | [FONT="]11.5[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0.5[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]14:00[/FONT] | [FONT="]28[/FONT] | [FONT="]11.5[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]16:00[/FONT][FONT="][/FONT] | [FONT="]25[/FONT] | [FONT="]11.5[/FONT] | [FONT="]15[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]18:00[/FONT] | [FONT="]21[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]4[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]20:00[/FONT][FONT="][/FONT] | [FONT="]33[/FONT] | [FONT="]11.5[/FONT] | [FONT="]17[/FONT] | [FONT="]0[/FONT] | [FONT="]2[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="] [/FONT] | [FONT="]22:00[/FONT] | [FONT="]35[/FONT] | [FONT="]11.5[/FONT] | [FONT="]18[/FONT] | [FONT="]0[/FONT] | [FONT="]1[/FONT] | [FONT="]20/64"[/FONT] | |||
[FONT="]28.10.13[/FONT] | [FONT="]00:00[/FONT][FONT="][/FONT] | [FONT="]35[/FONT] | [FONT="]11.5[/FONT] | [FONT="]18[/FONT] | [FONT="]0[/FONT] | [FONT="]0[/FONT][FONT="][/FONT] | [FONT="]20/64"[/FONT] | |||
<tbody>
</tbody>
[FONT="]So, the final output from two worksheets should look like:[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]08:00[/FONT] | [FONT="]12:00[/FONT] | [FONT="]16:00[/FONT] | [FONT="]20:00[/FONT] | [FONT="]00:00[/FONT] |
[FONT="]173L[/FONT] | [FONT="]0[/FONT] | [FONT="]1.5[/FONT] | [FONT="]8[/FONT] | [FONT="]3.5[/FONT] | [FONT="]6[/FONT] | [FONT="]0[/FONT] |
[FONT="]183L[/FONT] | [FONT="]1[/FONT] | [FONT="]0[/FONT] | [FONT="]0.5[/FONT] | [FONT="]0[/FONT] | [FONT="]2[/FONT] | [FONT="]1[/FONT] |
<tbody>
</tbody>
[FONT="]And finally, to make things more complicated, the monitoring hours vary, like in the table below:[/FONT]
[FONT="] [/FONT]
[FONT="]A[/FONT] | [FONT="]B[/FONT] | [FONT="]C[/FONT] | [FONT="]D[/FONT] | [FONT="]E[/FONT] | [FONT="]F[/FONT] | [FONT="]G[/FONT] | [FONT="]H[/FONT] | [FONT="]I[/FONT] |
[FONT="]175A[/FONT][FONT="][/FONT] | ||||||||
[FONT="]DATE[/FONT] | [FONT="]TIME[/FONT] | [FONT="]W[/FONT] | [FONT="]DS[/FONT] | [FONT="]WH[/FONT] | [FONT="]S[/FONT] | [FONT="]WC[/FONT] | [FONT="]E[/FONT] | [FONT="]C[/FONT] |
[FONT="] [/FONT] | [FONT="] [/FONT] | [FONT="]bar[/FONT] | [FONT="]bar[/FONT] | [FONT="]Co[/FONT] | [FONT="]22/64"[/FONT] | [FONT="]%[/FONT] | [FONT="]%[/FONT] | [FONT="]%[/FONT] |
[FONT="]27.10.13[/FONT] | [FONT="]00:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]31[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]00:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]32[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]01:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]37[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]01:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]40[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]02:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]39[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]02:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]41[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]03:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]36[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]03:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]33[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]35[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]04:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]38[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]05:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]40[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]05:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]37[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]06:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]33[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]06:30[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]20[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]36[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]07:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]27[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]08:00[/FONT] | [FONT="]40.5[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]29[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]09:00[/FONT] | [FONT="]40.5[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]35[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]10:00[/FONT] | [FONT="]40.5[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]26[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]11:00[/FONT] | [FONT="]40.5[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]29[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]12:00[/FONT] | [FONT="]40.5[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]32[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]13:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]31[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]14:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]28[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]15:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]42[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]16:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]36[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]17:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]27[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]18:00[/FONT] | [FONT="]41[/FONT] | [FONT="]10[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]32[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]19:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]36[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]20:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]31[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]21:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]34[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]22:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]29[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="] [/FONT] | [FONT="]23:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]33[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
[FONT="]28.10.13[/FONT] | [FONT="]00:00[/FONT] | [FONT="]40[/FONT] | [FONT="]9.5[/FONT] | [FONT="]18[/FONT] | [FONT="]16/64"[/FONT] | [FONT="]31[/FONT] | [FONT="] [/FONT] | [FONT="]trace[/FONT] |
<tbody>
</tbody>
[FONT="]With this worksheet (175A), my final output should look like this:[/FONT]
[FONT="] [/FONT] | [FONT="]04:00[/FONT] | [FONT="]08:00[/FONT] | [FONT="]12:00[/FONT] | [FONT="]16:00[/FONT] | [FONT="]20:00[/FONT] | [FONT="]00:00[/FONT] |
[FONT="]173L[/FONT] | [FONT="]0[/FONT] | [FONT="]1.5[/FONT] | [FONT="]8[/FONT] | [FONT="]3.5[/FONT] | [FONT="]6[/FONT] | [FONT="]0[/FONT] |
[FONT="]183L[/FONT] | [FONT="]1[/FONT] | [FONT="]0[/FONT] | [FONT="]0.5[/FONT] | [FONT="]0[/FONT] | [FONT="]2[/FONT] | [FONT="]1[/FONT] |
[FONT="]175A[/FONT] | [FONT="]35[/FONT] | [FONT="]29[/FONT] | [FONT="]32[/FONT] | [FONT="]36[/FONT] | [FONT="]31[/FONT] | [FONT="]31[/FONT] |
<tbody>
</tbody>
[FONT="]Since there are no value at column “H”, divided by a factor of “2” is skipped.[/FONT]
[FONT="] [/FONT]
[FONT="]Here is a code I used before, and it executes part of the required job:[/FONT]
[FONT="] [/FONT]
[FONT="]Dim myrow As Long[/FONT]
[FONT="]Dim wksTo As Worksheet[/FONT]
[FONT="]Dim j, s As Long[/FONT]
[FONT="]Dim lastRow, lastsheet As Long[/FONT]
[FONT="]Dim wks As Worksheet[/FONT]
[FONT="]Dim sn As String[/FONT]
[FONT="] [/FONT]
[FONT="] Sheets(1).Select[/FONT]
[FONT="] Sheets.Add.Name = "wksTo"[/FONT]
[FONT="] lastRow = 2 ' set the first row to use, set to 2 so you can add labels in row 1[/FONT]
[FONT="] lastsheet = Sheets.Count[/FONT]
[FONT="] For s = 2 To lastsheet ' Loop thru sheets[/FONT]
[FONT="] Worksheets(s).Activate[/FONT]
[FONT="] With Worksheets(s) ' sheet(s) changes sheets[/FONT]
[FONT="] On Error Resume Next[/FONT]
[FONT="] myrow = .Columns("A").Find(Date).Row[/FONT]
[FONT="] Application.Goto .Range("A" & myrow), True[/FONT]
[FONT="] End With[/FONT]
[FONT="] [/FONT]
[FONT="] With Worksheets(s)[/FONT]
[FONT="] ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Activate[/FONT]
[FONT="] End With[/FONT]
[FONT="] [/FONT]
[FONT="] With Application.ActiveWindow.ActiveCell[/FONT]
[FONT="] dc = 0[/FONT]
[FONT="] sn = Sheets(s).Name[/FONT]
[FONT="] Worksheets("wksTo").Range("G" & lastRow).Formula = sn[/FONT]
[FONT="] For j = 1 To -10 Step -2[/FONT]
[FONT="] Range(.Cells(j, 6), .Cells(j, 6)).Copy Sheets("wksTo").Cells(lastRow, 8 - dc)[/FONT]
[FONT="] dc = dc + 1[/FONT]
[FONT="] Next j[/FONT]
[FONT="] lastRow = lastRow + 1[/FONT]
[FONT="] End With[/FONT]
[FONT="] Next s[/FONT]
[FONT="] [/FONT]
[FONT="] Dim x As Integer[/FONT]
[FONT="] Worksheets("wksTo").Activate[/FONT]
[FONT="] For x = 1 To Worksheets.Count[/FONT]
[FONT="] Cells(x, 1).Value = Worksheets(x).Name[/FONT]
[FONT="] Next x[/FONT]
Dear all,
I need some help in writing a code for the following:
I have a workbook with 11 worksheets in it. Each worksheet has a unique name (such as 167L, 167S, 170S, 170L, 173S, 173L, 175A, 183S, 183L and etc.). Each of the worksheet is updated daily and I need to extract data from specific columns and according to specific time.
A | B | C | D | E | F | G | H | I |
173L | ||||||||
DATE | TIME | W | DS | WH | S | WC | E | C |
bars | bars | C0 | % | % | % | 0/64" | ||
27.10.13 | 00:00 | 95 | 28 | 18 | 0 | 0 | 0 | 24/64" |
| 02:00 | 91 | 28 | 18 | 0 | 0 | 2 | 24/64" |
| 04:00 | 89 | 28 | 17 | 0 | 0 | 0 | 24/64" |
| 06:00 | 93 | 28 | 16 | 0 | 0 | 1 | 24/64" |
| 08:00 | 95 | 28 | 16 | 0 | 0 | 3 | 24/64" |
| 10:00 | 90 | 28 | 16 | 0 | 0 | 12 | 24/64" |
| 12:00 | 89 | 28 | 14 | 0 | 0 | 16 | 24/64" |
| 14:00 | 92 | 28 | 14 | 0 | 0 | 5 | 24/64" |
| 16:00 | 95 | 28 | 15 | 0 | 0 | 7 | 24/64" |
| 18:00 | 92 | 28 | 14 | 0 | 0 | 8 | 24/64" |
| 20:00 | 93 | 28 | 14 | 0 | 0 | 12 | 24/64" |
| 22:00 | 90 | 28 | 14 | 0 | 0 | 6 | 24/64" |
28.10.13 | 00:00 | 98 | 28 | 14 | 0 | 0 | 0 | 24/64" |
<tbody>
</tbody>
Basically, the code I have used before I was assisted by the www.mrexcel.com/forum before, however, I need to have it devised in a bit different way (pls visit the www….. for details). The code I need should (a) select values at column “B” (the corresponding values are 04:00, 08:00, 12:00, 16:00, 20:00 and 00:00), copy value in column “G” (0, 0, 0, 0, 0, 0) and sum up with values from column “H”, which before being added should be divided by a factor of “2” (0/2=0, 3/2=1.5, 16/2=8, 7/2=3.5, 12/2=6, 0/2=0). The summed values should be copied and pasted into a separate worksheet and it needs to look like this:
| 04:00 | 08:00 | 12:00 | 16:00 | 20:00 | 00:00 |
173L | 0 | 1.5 | 8 | 3.5 | 6 | 0 |
| | | | | | |
<tbody>
</tbody>
A | B | C | D | E | F | G | H | |||
183L | ||||||||||
DATE | TIME | W | DS | WH | S | WC | C | |||
bars | bars | C0 | % | % | 0/64" | |||||
27.10.13 | 00:00 | 30 | 11.5 | 17 | 0 | 3 | 20/64" | |||
| 02:00 | 34 | 11.5 | 17 | 0 | 1 | 20/64" | |||
| 04:00 | 38 | 11.5 | 17 | 0 | 1 | 20/64" | |||
| 06:00 | 38 | 11.5 | 17 | 0 | 2 | 20/64" | |||
| 08:00 | 37 | 11.5 | 15 | 0 | 0 | 20/64" | |||
| 10:00 | 36 | 11.5 | 15 | 0 | 0 | 20/64" | |||
| 12:00 | 31 | 11.5 | 15 | 0 | 0.5 | 20/64" | |||
| 14:00 | 28 | 11.5 | 15 | 0 | 0 | 20/64" | |||
| 16:00 | 25 | 11.5 | 15 | 0 | 0 | 20/64" | |||
| 18:00 | 21 | 11.5 | 17 | 0 | 4 | 20/64" | |||
| 20:00 | 33 | 11.5 | 17 | 0 | 2 | 20/64" | |||
| 22:00 | 35 | 11.5 | 18 | 0 | 1 | 20/64" | |||
28.10.13 | 00:00 | 35 | 11.5 | 18 | 0 | 0 | 20/64" | |||
<tbody>
</tbody>
So, the final output from two worksheets should look like:
| 04:00 | 08:00 | 12:00 | 16:00 | 20:00 | 00:00 |
173L | 0 | 1.5 | 8 | 3.5 | 6 | 0 |
183L | 1 | 0 | 0.5 | 0 | 2 | 1 |
<tbody>
</tbody>
And finally, to make things more complicated, the monitoring hours vary, like in the table below:
A | B | C | D | E | F | G | H | I |
175A | ||||||||
DATE | TIME | W | DS | WH | S | WC | E | C |
| | bar | bar | Co | 22/64" | % | % | % |
27.10.13 | 00:00 | 40 | 9 | 20 | 16/64" | 31 | | trace |
| 00:30 | 40 | 9 | 20 | 16/64" | 32 | | trace |
| 01:00 | 40 | 9 | 20 | 16/64" | 37 | | trace |
| 01:30 | 40 | 9 | 20 | 16/64" | 40 | | trace |
| 02:00 | 40 | 9 | 20 | 16/64" | 39 | | trace |
| 02:30 | 40 | 9 | 20 | 16/64" | 41 | | trace |
| 03:00 | 40 | 9 | 20 | 16/64" | 36 | | trace |
| 03:30 | 40 | 9 | 20 | 16/64" | 33 | | trace |
| 04:00 | 40 | 9 | 20 | 16/64" | 35 | | trace |
| 04:30 | 40 | 9 | 20 | 16/64" | 38 | | trace |
| 05:00 | 40 | 9 | 20 | 16/64" | 40 | | trace |
| 05:30 | 40 | 9 | 20 | 16/64" | 37 | | trace |
| 06:00 | 40 | 9 | 20 | 16/64" | 33 | | trace |
| 06:30 | 40 | 9 | 20 | 16/64" | 36 | | trace |
| 07:00 | 40 | 9 | 18 | 16/64" | 27 | | trace |
| 08:00 | 40.5 | 10 | 18 | 16/64" | 29 | | trace |
| 09:00 | 40.5 | 10 | 18 | 16/64" | 35 | | trace |
| 10:00 | 40.5 | 10 | 18 | 16/64" | 26 | | trace |
| 11:00 | 40.5 | 10 | 18 | 16/64" | 29 | | trace |
| 12:00 | 40.5 | 10 | 18 | 16/64" | 32 | | trace |
| 13:00 | 41 | 10 | 18 | 16/64" | 31 | | trace |
| 14:00 | 41 | 10 | 18 | 16/64" | 28 | | trace |
| 15:00 | 41 | 10 | 18 | 16/64" | 42 | | trace |
| 16:00 | 41 | 10 | 18 | 16/64" | 36 | | trace |
| 17:00 | 41 | 10 | 18 | 16/64" | 27 | | trace |
| 18:00 | 41 | 10 | 18 | 16/64" | 32 | | trace |
| 19:00 | 40 | 9.5 | 18 | 16/64" | 36 | | trace |
| 20:00 | 40 | 9.5 | 18 | 16/64" | 31 | | trace |
| 21:00 | 40 | 9.5 | 18 | 16/64" | 34 | | trace |
| 22:00 | 40 | 9.5 | 18 | 16/64" | 29 | | trace |
| 23:00 | 40 | 9.5 | 18 | 16/64" | 33 | | trace |
28.10.13 | 00:00 | 40 | 9.5 | 18 | 16/64" | 31 | | trace |
<tbody>
</tbody>
With this worksheet (175A), my final output should look like this:
| 04:00 | 08:00 | 12:00 | 16:00 | 20:00 | 00:00 |
173L | 0 | 1.5 | 8 | 3.5 | 6 | 0 |
183L | 1 | 0 | 0.5 | 0 | 2 | 1 |
175A | 35 | 29 | 32 | 36 | 31 | 31 |
<tbody>
</tbody>
Since there are no value at column “H”, divided by a factor of “2” is skipped.
Here is a code I used before, and it executes part of the required job:
Dim myrow As Long
Dim wksTo As Worksheet
Dim j, s As Long
Dim lastRow, lastsheet As Long
Dim wks As Worksheet
Dim sn As String
Sheets(1).Select
Sheets.Add.Name = "wksTo"
lastRow = 2 ' set the first row to use, set to 2 so you can add labels in row 1
lastsheet = Sheets.Count
For s = 2 To lastsheet ' Loop thru sheets
Worksheets(s).Activate
With Worksheets(s) ' sheet(s) changes sheets
On Error Resume Next
myrow = .Columns("A").Find(Date).Row
Application.Goto .Range("A" & myrow), True
End With
With Worksheets(s)
ActiveCell.Offset(rowoffset:=0, columnoffset:=1).Activate
End With
With Application.ActiveWindow.ActiveCell
dc = 0
sn = Sheets(s).Name
Worksheets("wksTo").Range("G" & lastRow).Formula = sn
For j = 1 To -10 Step -2
Range(.Cells(j, 6), .Cells(j, 6)).Copy Sheets("wksTo").Cells(lastRow, 8 - dc)
dc = dc + 1
Next j
lastRow = lastRow + 1
End With
Next s
Dim x As Integer
Worksheets("wksTo").Activate
For x = 1 To Worksheets.Count
Cells(x, 1).Value = Worksheets(x).Name
Next x