Results 1 to 10 of 193

Thread: Appendix Thread 2. ( Codes for other Threads, HTML Tables, etc.)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10

    Code For Nelson

    Hi Nelson,
    I think both
    _ the ways to do this,
    _and the possibly output forms
    are infinite

    _ You must try to be a bit more precise in exactly what you want.

    _ I have done another fairly simple code:

    It is here:
    http://www.excelfox.com/forum/showth...0047#post10047

    It runs though all the Worksheets to calculate normal overtime and holiday overtime. The total added for all Worksheets is displayed in a message box:
    NelsonMessageBox.jpg http://imgur.com/XSvQpQi
    NelsonMessageBox.JPG




    I expect the code is not yet want you finally want. It tells you the total sum for Normal Overtime and Holiday overtime.
    ( I still do not understand what calculations should be done for total days )

    Please start a new Thread here: _.. http://www.excelfox.com/forum/forumd...p/2-Excel-Help

    _.. Please try again to explain exactly what you want.
    _.. I will then look at it again for you on Monday


    Alan

    Code:
    Code:
    ' An Initial code for Nelson for Post in this Forum    http://www.excelfox.com/forum/forumdisplay.php/2-Excel-Help
    Sub SomeingSumTotals()          '  https://www.dropbox.com/s/u76eo5trrtppgoi/SAMPLE2.xlsx?dl=0
    Rem 1) Worksheets info.
    Dim WsStear As Worksheet        ' Dim: For Object variabls: Address location to a "pointer". That has all the actual memory locations (addresses) of the various property values , and it holds all the instructions what / how to change them , should that be wanted later. That helped explain what occurs when passing an Object to a Call ed Fucntion or Sub Routine By Val ue. In such an occurance, VBA actually  passes a copy of the pointer.  So that has the effect of when you change things like properties on the local variable , then the changes are reflected in changes in the original object. (The copy pointer instructs how to change those values, at the actual address held in that pointer). That would normally be the sort of thing you would expect from passing by Ref erence.  But as that copy pointer "dies" after the called routine ends, then any changes to the Addresses of the Object Properties in the local variable will not be reflected in the original pointer. So you cannot actually change the pointer.)
                                    ' Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
    Rem 2) varables for some totals ;)
    Dim NOHrsV2 As Double, HOHrsV2 As Double, TDays As Long
     Let NOHrsV2 = 0: Let HOHrsV2 = 0: Let TDays = 0
    Rem 3) Loop through worksheets and give some Totals
    Dim Cnt As Long ' Loop Bound variable count for going through all worksheets
        For Cnt = 1 To ThisWorkbook.Worksheets.Count
         Set WsStear = ThisWorkbook.Worksheets.Item(Cnt)                   ' Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
        Dim lr As Long                                                     ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in.  '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
         Let lr = WsStear.Range("E" & Rows.Count & "").End(xlUp).Row       ' The Range Object ( cell ) that is the last cell in the column of interest (CHOOSE a column typically that will always have a last Entry in any Data) ,( Row Number given by .Count Property applied to ( any Worksheet would do, so leaving unqualified is OK here, ) Spreadsheet Range Rows Property)    has the Property .End ( argument "Looking back up" ) appled to it. This Returns a new Range ( cell ) object which is that of the first Range ( cell ) with something in it "looking back up" in the XL spreadsheet from that last Cell. Then the .Row Property is applied to return a long number equal to the Row number of that cell:     Rows.Count is the very last row number in your Worksheet. It is different for earlier versions of Excel.  The End(xlUp) is the same as pressing a Ctrl+UpArrow key combination. The final ".Row" returns the row where the cursor stops after moving up.
        Dim FstDtaCel As Range: Set FstDtaCel = WsStear.Range("A2")        ' Worksheets Range(" ") Property used to return Range object of first cell in second row
        Dim arrInNorm() As Variant, arrInOver() As Variant                 ' In the next lines the .Value2 Property is applied a Range object which presents the the Value2 value or values in a single variable of appropriate type or a field of member Elements of varaint types.We are expecting the latter, so declare ( Dim ) a dynamic Array variable appropriately. It must be dynamic as its size will be defined at that assignment
         Let arrInNorm() = FstDtaCel.Offset(0, 8).Resize(lr - 1, 1).Value2 ' One thing you pick up when learning VBA programming is that referring to cells from one to another via an offset is both fundamental and efficient. That makes sense as Excel is all about using the offsets mentioned above. So like if you use them you can “cut out the middle man”. ( The middle man here might be considered as, for example, in VBA, using extra variables for different Range objects: A fundamental thing to do with any cell ( or strictly speaking the Range object associated to a cell ) is the Range Item Property of any range Object, through which you can “get at” any other Range object. http://www.excelforum.com/showthread.php?t=1154829&page=13&p=4563838&highlight=#post4563838 ( It is often quicker than using a separate variable for each Range object – probably as all the variable does is hold the offset , so you might as well use the offset in the first place.. ) )
         Let arrInOver() = FstDtaCel.Offset(0, 9).Resize(lr - 1, 1).Value2 ' Similarly Another thing you pick up along the way is that the cells ( or strictly speaking the Range objects associated with it ) can be organised into groups of cells which then are also called Range objects and are organised in their constituent parts exactly the same as for the single cell Range object. Once again this is all an indication of organising so that we get at information by sliding along a specific amount ( offset value). The Offset and Resize properties therefore return a new range object. I use the .Value 2 here as i seemed to get it for .Value anyway, not sure why yet, - so i thought be on the safe side , get it always and work somehow with that for now and convert as necerssary.
        Dim ShtCnt As Long ' Loop Bound Variable Count for hours columns looping
            For ShtCnt = 1 To UBound(arrInNorm(), 1) Step 1
                If arrInNorm(ShtCnt, 1) <> 0 And arrInOver(ShtCnt, 1) <> 0 Then Let NOHrsV2 = NOHrsV2 + arrInOver(ShtCnt, 1)
                If arrInNorm(ShtCnt, 1) = 0 And arrInOver(ShtCnt, 1) <> 0 Then Let HOHrsV2 = HOHrsV2 + arrInOver(ShtCnt, 1)
            Next ShtCnt
        Next Cnt
    Rem 4) Output some totals ;)
     MsgBox prompt:="Normal Overtime is " & NOHrsV2 * 24 & vbCrLf & "Holiday Overtime is" & HOHrsV2 * 24 ' NelsonMessageBox.jpg     http://imgur.com/XSvQpQi
    '4b) Tell you Totals                                                   ' Sub Speach() '                                        Richard Buttrey   http://www.excelforum.com/showthread.php?t=1164765&p=4535112#post4535112
    Dim Saps As Object
     Set Saps = CreateObject("SAPI.SpVoice")
     Saps.Speak "Hello Nelson. These are Sum totals for Normal Overtime and Holiday Overtime for the two Worksheets you gave.. Normal Overtime is " & NOHrsV2 * 24 & "..  Holiday Overtime is " & HOHrsV2 * 24 & ".. I expect this is not yet quite what you want."
    '                                                                      ' End Sub
    End Sub

    Test
    https://youtu.be/xLCWtC6UYrM?t=150

    https://www.youtube.com/watch?v=xLCW...0C3q3gx4AaABAg

    https://www.microsoft.com/en-us/soft...load/windows10

    Hold keys Ctrl+Shift , then press key I to get development mode

    Hit the 3 dots

    More tools
    https://www.microsoft.com/de-de/soft...d/windows10ISO
    https://i.postimg.cc/7LznW4QR/Hold-k...pment-mode.jpg
    https://i.postimg.cc/0yFCnjZm/Hit-the-3-dots.jpg
    https://i.postimg.cc/Dw8g1LQn/More-Tools.jpg
    https://i.postimg.cc/5N9pNZ6H/More-t...conditions.jpg
    https://i.postimg.cc/RhdRLTbV/User-A...-Chrome-OS.jpg https://i.postimg.cc/050cv82R/Chrome-OS.jpg
    https://i.postimg.cc/wvhF7zXN/Hit-Refresh.jpg


    https://www.microsoft.com/de-de/soft...d/windows10ISO
    https://i.postimg.cc/hGQ2RThp/Edition-Multi-Edition.jpg
    https://i.postimg.cc/VvmgthgV/English-US.jpg





    https://i.postimg.cc/7Z6BXp4v/Generic-Keys.jpg
    https://i.postimg.cc/wT94R1bj/Generic-Keys.jpg
    https://i.postimg.cc/c4T9RdVM/Generic-Keys.jpg
    https://i.postimg.cc/1txJmXqP/Generic-Keys.jpg

    Generic keys https://www.youtube.com/watch?t=440

    https://christitus.com/ntlite-guide/


    Dec 2023 https://eileenslounge.com/viewtopic.php?f=56&t=40330
    Link zu dieser Galerie: https://postimg.cc/gallery/m4f5hF9



    https://i.postimg.cc/xdvDsfrk/64-Bit.jpg
    https://i.postimg.cc/j2dbwGFD/a-Edit...ti-Edition.jpg
    https://i.postimg.cc/SRTpWDBD/b-English-US.jpg
    https://i.postimg.cc/LXmdwcRx/d-Hold...pment-mode.jpg
    https://i.postimg.cc/50pcVs2b/e-Hit-the-3-dots.jpg
    https://i.postimg.cc/SNR4yb95/f-More-Tools.jpg
    https://i.postimg.cc/7YRkhtML/g-More...conditions.jpg
    https://i.postimg.cc/CKTpHZ2T/h-User...-Chrome-OS.jpg
    https://i.postimg.cc/tR2yQ4sW/hi-Chrome-OS.jpg
    https://i.postimg.cc/13NZq0Jr/j-Hit-Refresh.jpg




    
    Attached Files Attached Files
    Last edited by DocAElstein; 12-30-2023 at 02:27 AM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. VBA to Reply All To Latest Email Thread
    By pkearney10 in forum Outlook Help
    Replies: 11
    Last Post: 12-22-2020, 11:15 PM
  2. Appendix Thread. Diet Protokol Coding Adaptions
    By DocAElstein in forum Test Area
    Replies: 6
    Last Post: 09-05-2019, 10:45 AM
  3. Replies: 19
    Last Post: 04-20-2019, 02:38 PM
  4. Search List of my codes
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 08-03-2014, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •