Page 15 of 56 FirstFirst ... 5131415161725 ... LastLast
Results 141 to 150 of 553

Thread: Tests Copying pasting Cliipboard issues

  1. #141
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    Notes in support of these excelfox Threads and posts:
    http://www.excelfox.com/forum/showth...ista-and-Excel
    http://www.excelfox.com/forum/showth...r-CMS-Software
    https://www.ebay.de/itm/323782698418?ul_noapp=true , _ https://imgur.com/Xq2hih2



    First Cloud attempts.


    Tests Friday, 7th June 2019.

    OK I make Today two tries on one computer : Computer Acer Aspire 4810TZG Vista Operating System
    _1 Try one: My computer is connected to the internet using the same router as that to which the Sannce 1080N Receiver is successfully connected . (German Telekom Speedport W504V Router LAN RJ45 Internet connection)
    Delete a desktop "Deinstaller CMS" icon

  2. #142
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    Notes in support of these main Threads and posts:
    http://www.excelfox.com/forum/showth...t-new-range-in
    https://excel.tips.net/T002042_Inser...ying_Rows.html
    *** see refs also


    I tend to think of the Excel VBA Range.Insert method*** as primarily something that …… makes a space to put new range in ……( https://tinyurl.com/y2cup4o8 )
    If something happens to be in the clipboard when you use this code line, then VBA makes some assumption that you wanted what is in the clipboard put in the space. Exactly what it decides to do takes a book of explanation, ( http://www.excelfox.com/forum/showth...ll=1#post10441 ). It is left for us to figure out as there is no documentation that I know of
    In the simplest case of having a single row in the clipboard, and using the Range.Insert to make a whole row as a space, then the results are as you expect, since the obvious choice that Excel makes is to assume you want to put that copied row in the new row space.
    That is what Allen Wyatt's*** first routine does. It inserts a new empty row at the active row ( or row containing the active cell ) , but also what is in the clipboard, ( the original row ) , is put into this new row. What actually is happening is that the original row has been shifted down. A copy of that original ( which was firstly made ) , is put in the new row space
    In the second routine, he uses the Range.Insert method with nothing in the clipboard so that it just makes the row space, ( this time he inserts that space one row down ). Then he copies the row and pastes it into the new row space.
    So his two routines demonstrate well the points I am trying to make.

    To copy just some of a row to a new row:
    Using something similar to the second routine is the better alternative for only copying some of the original row to the new row space. ( The other alternative of trying to manipulate and then predict how the Range.Insert will handle a modified clipboard content is certainly possible and academically interesting, but might be a little advanced if you are VBA beginner, especially as the various Bugs and unknowns in the various Microsoft clipboards has been proven in recent years to be beyond the understanding of the Microsoft programmers themselves!! )
    So, for example, the general idea would be
    _1,
    ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown
    Or, as example
    ActiveCell.Offset(1, 0).EntireRow.Resize(1, 14).Insert Shift:=xlDown
    _2, The simplest way, or first idea that springs to mind for me, is to copy the row info you want to a simple array, and then manipulate it to remove/ leave blank the info that you do not want, then paste that into the space.

    Here is a couple of routine examples, here I want just columns A to F from a row A to H
    Code:
    Sub Testies2a()
    Rem 1 make a space by moving ( Shift -ing )  the rows down
     ActiveCell.Offset(1, 0).EntireRow.Resize(1, 8).Insert Shift:=xlDown ' when I Re size a range, it starts at the top left of the range, which will be in the first column either for a row or for a range starting in column 1
    Rem 2 put the current active row in an array
    Dim arrAH() As Variant ' The reason I need Variant is that the next line allows me to capture an entire range in one go, using the .Value property which returns the values in Variant type elements. So the type definition must match.
     Let arrAH() = ActiveCell.EntireRow.Resize(1, 8).Value ' so my array now holds cell values from columns A-H ( columns 1-8 )
    '2b  remove the values you do not want
     Let arrAH(1, 7) = "": Let arrAH(1, 8) = ""
    Rem 3 paste out modified array
     Let ActiveCell.Offset(1, 0).EntireRow.Resize(1, 8).Value = arrAH() ' VBA lets me do the opposite of the capture to paste out array values in oone go
    End Sub
    Sub Testies2b()
    Rem 1 make a space by moving ( Shift -ing )  the rows down
     ActiveCell.Offset(1, 0).EntireRow.Resize(1, 8).Insert Shift:=xlDown ' when I Re size a range, it starts at the top left of the range, which will be in the first column either for a row or for a range starting in column 1
    Rem 2 put the current active row in an array
    Dim arrAH() As Variant ' The reason I need Variant is that the next line allows me to capture an entire range in one go, using the .Value property which returns the values in Variant type elements. So the type definition must match.
     Let arrAH() = ActiveCell.EntireRow.Resize(1, 6).Value ' so my array now holds cell values from columns A-F ( columns 1-6 )
    Rem 3 paste out modified array
     Let ActiveCell.Offset(1, 0).EntireRow.Resize(1, 6).Value = arrAH() ' VBA lets me do the opposite of the capture to paste out array values in oone go
    End Sub
    As example, if you start with this, with say cell B2 selected:
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    A1 B1 C1 D1 E1 F1 G1 H1 I1
    2
    A2 B2 C2 D2 E2 F2 G2 H2 I2
    3
    A3 B3 C3 D3 E3 F3 G3 H3 I3
    4
    A4 B4 C4 D4 E4 F4 G4 H4 I4


    Then using that test data, after running either routine you will get this:

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    A1 B1 C1 D1 E1 F1 G1 H1 I1
    2
    A2 B2 C2 D2 E2 F2 G2 H2 I2
    3
    A2 B2 C2 D2 E2 F2 I3
    4
    A3 B3 C3 D3 E3 F3 G3 H3 I4


    _._________________________________


    The next routine, I think will do something close to your specific question, the row to be copied is columns A-N , and you want G and H left blank

    Code:
    Sub Testies3()
    Rem 1 make a space by moving ( Shift -ing )  the rows down
     ActiveCell.Offset(1, 0).EntireRow.Resize(1, 14).Insert Shift:=xlDown '
    Rem 2 put the current active row in an array
    Dim arrAH() As Variant '
     Let arrAH() = ActiveCell.EntireRow.Resize(1, 14).Value ' so my array now holds cell values from columns A-N ( columns 1-14 )
    '2b  remove the values you do not want
     Let arrAH(1, 7) = "": Let arrAH(1, 8) = ""
    Rem 3 paste out modified array
     Let ActiveCell.Offset(1, 0).EntireRow.Resize(1, 14).Value = arrAH() '
    End Sub

    ref:
    Allen Wyatt *** https://excel.tips.net/T002042_Inser...ying_Rows.html
    *** https://docs.microsoft.com/en-us/off...l.range.insert



  3. #143
    Junior Member
    Join Date
    Jun 2019
    Posts
    11
    Rep Power
    0
    Hi Alan... Thank you so much for the code... It does exactly what I wanted..

    Also, thank you for your explanation as this has helped be understand more of what the code does... sometime this is more important than the solution itself.

    Keep up the good work.

    Thanks again

    Paul

  4. #144
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    You're welcome , Paul , thanks for the feedback

  5. #145
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10

    macro recording example

    In support of this Thread in main Forums:
    http://www.excelfox.com/forum/showth...d-on-condition

    A macro recording example to get some coding to help answer this……
    Quote Originally Posted by rider@1234 View Post
    all files are located in desktop
    vba is placed ........
    all files are located in desktop
    vba is placed in seperate file
    only 1 file is opened and that is vba code placed file so for this process we have to open the file as per condition and after the process completed all files should be saved and closed except vba placed file
    If column R of 1.xls file is not in minus(-1,-0.5 or xyz any negative number) then see the column E data of 1.xls and open 2.xlsx and match column E of 1.xls with column A of 2.xlsx
    and if it matches then look for any highlighted colour in that row and if any highlighted cell in that row is found then remove the highlighted colour and save the file and close all the file






    Open Excel. ( I have Office 2007 ).

    Turn on the macro recorder
    Turn On Macro Recorder.jpg : https://imgur.com/uZkZWg1
    ( I use the default macro name and place for the coding to be stored )
    Use default macro name and place where macro is stored.jpg : https://imgur.com/rR8UkT1

    I open a new file.
    Open new file.jpg : https://imgur.com/10pnrBL
    ( I am in Excel 2007, so I end up with a .xlsx file
    New xlsx File.JPG : https://imgur.com/vvqEC1w

    I save this file on the desktop, giving it the name "MainMacroFile"
    Save As.jpg : https://imgur.com/PrnZhAW
    Save As xlsx.JPG : https://imgur.com/PrnZhAW


    I resave as a file to hold macros:
    Save As xlsm.JPG https://imgur.com/5hVZAld


    I open a new file
    Open new file.jpg : https://imgur.com/vvqEC1w
    ( I am in Excel 2007, so I end up with a .xlsx file
    New xlsx File.JPG : https://imgur.com/vvqEC1w
    I save this file on the desktop, giving it the name "1"
    Save As.jpg : https://imgur.com/PrnZhAW
    Save As 1_xlsx.JPG https://imgur.com/y2uMg0i

    I resave as a 1.xls
    Save As.jpg : https://imgur.com/PrnZhAW
    Save As 1_xls.JPG : https://imgur.com/iylw8r7


    I close the file "1.xls"
    Close 1_xls.jpg : https://imgur.com/vJtdLHo
    I open the file "1.xls"
    Open 1_xls.jpg : https://imgur.com/de2MGkt
    Open 1_xls.jpg : https://imgur.com/zafLOTd


    I now take some actions, …. which are similar to your …. If column R of 1.xls file is not in minus(-1,-0.5 or xyz any negative number) then see the column E data of 1.xls and open 2.xlsx and match column E of 1.xls with column A of 2.xlsx
    and if it matches then look for any highlighted colour in that row and if any highlighted cell in that row is found
    …..
    What I actually did was
    _ Put some positive numbers in column R
    _ Put some letters in column E
    _ Put some highlight in column E
    Add some numbers letters and highlighting.JPG : https://imgur.com/6ZYeaxU
    _ I take some of the highlighting off
    Take some highlighting off.jpg : https://imgur.com/Z1Rk9HD
    I save the file "1.xls"
    Save 1_xls.jpg : https://imgur.com/FmLrhjZ
    I close the file "1.xls"
    Close 1_xls.jpg : https://imgur.com/R6eqv1m

    I make a new file, "2.xlsx" , on the desktop
    New xlsx File.JPG : https://imgur.com/vvqEC1w
    Save As 2_xlsx.JPG : https://imgur.com/mHacZ74


    I close the file and open it
    Close 2_xlsx.jpg : https://imgur.com/tReoAJG
    Open 2_xlsx.jpg : https://imgur.com/jmsqNY1
    Open 2_xlsx.jpg : https://imgur.com/J3XPhz5


    I put a letter in column A of "2.xlsx"
    Put a letter in column A of 2_xlsx.JPG : https://imgur.com/9o8PTYQ
    I save the file "2.xlsx"
    Save 2_xlsx.jpg : https://imgur.com/ehSxG6b
    I close the file "2.xlsx"
    Close 2_xlsx.jpg : https://imgur.com/YyRmhfW

    I now stop the macro recorder
    Stop macro recorder.JPG : https://imgur.com/NrcDQS4
    Stop macro recorder.JPG : https://imgur.com/WRgy3mB



    Find the macro just recorded and click on Step Into
    Find macro just recorded.JPG : https://imgur.com/xK3abHT
    Find macro just recorded.JPG : https://imgur.com/34U5nm3

    ( Alternatively hit Alt+F8 )

    You can then see the recorded macro
    Recorded Macro.JPG : https://imgur.com/Mo0vfHi


    I include the code below, but have also added some 'Comments ( ' Rems) to show the steps which I manually made above

    Code:
    Sub Makro1()
    '
    ' Makro1 Makro
    '
    
    '
    ' Rem I open a  new file.
        Workbooks.Add
    ' Rem I save this file on the desktop, giving it the name "MainMacroFile"
        ChDir "C:\Users\Elston\Desktop"
        ActiveWorkbook.SaveAs Filename:="C:\Users\Elston\Desktop\MainMacroFile.xlsx" _
            , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    ' Rem I resave as a file to hold macros
        ActiveWorkbook.SaveAs Filename:="C:\Users\Elston\Desktop\MainMacroFile.xlsm" _
            , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
        
    ' Rem I open a  new file.
        Workbooks.Add
    ' Rem I save this file on the desktop, giving it the name "1"
        ActiveWorkbook.SaveAs Filename:="C:\Users\Elston\Desktop\1.xlsx", FileFormat _
            :=xlOpenXMLWorkbook, CreateBackup:=False
    ' Rem I resave as a 1.xls
        ActiveWorkbook.SaveAs Filename:="C:\Users\Elston\Desktop\1.xls", FileFormat _
            :=xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
            False, CreateBackup:=False
    ' Rem I close the file "1.xls"
        ActiveWorkbook.Close
    ' Rem I open the file "1.xls"
        Workbooks.Open Filename:="C:\Users\Elston\Desktop\1.xls"
        
    ' Rem I now take some actions, ….       .......  If column R of 1.xls file is not in minus(-1,-0.5 or xyz any negative number) then see the column E data of 1.xls and open 2.xlsx and match column E of 1.xls with column A of 2.xlsx
        Range("R1").Select
        ActiveCell.FormulaR1C1 = "1"
        Range("R2").Select
        ActiveCell.FormulaR1C1 = "2"
        Range("R3").Select
        ActiveCell.FormulaR1C1 = "3"
        Range("E1").Select
        ActiveCell.FormulaR1C1 = "a"
        Range("E2").Select
        ActiveCell.FormulaR1C1 = "b"
        Range("E3").Select
        ActiveCell.FormulaR1C1 = "c"
        Range("E4").Select
        ActiveCell.FormulaR1C1 = "d"
        Range("E1:E4").Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    ' Rem  _ I take some of the highlighting off
        Range("E2").Select
        With Selection.Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
        Range("E3").Select
        With Selection.Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    ' Rem I save the file "1.xls"
        ActiveWorkbook.Save
    ' Rem I close the file "1.xls"
        ActiveWorkbook.Close
        
    ' Rem I make a new file, "2.xlsx" , on the desktop
        Workbooks.Add
        ActiveWorkbook.SaveAs Filename:="C:\Users\Elston\Desktop\2.xlsx", FileFormat _
            :=xlOpenXMLWorkbook, CreateBackup:=False
    ' Rem I close the file and open it
        ActiveWorkbook.Close
        Workbooks.Open Filename:="C:\Users\Elston\Desktop\2.xlsx"
        
    ' Rem I put a letter in column A of "2.xlsx"
        Range("A4").Select
        ActiveCell.FormulaR1C1 = "d"
        Range("A5").Select
    ' Rem I save the file "2.xlsx"
        ActiveWorkbook.Save
    ' Rem I close the file "2.xlsx"
        ActiveWorkbook.Close
    
    
    ' Rem I now stop the macro recorder
    End Sub

  6. #146
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    In support of answer to this main excelfox Excel Forum Thread: http://www.excelfox.com/forum/showth...1188#post11188

    _____ Workbook: 1.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    1
    a
    1
    2
    b
    2
    3
    c
    3
    4
    d
    Worksheet: Tabelle1






    _____ Workbook: 2.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    1
    2
    3
    4
    d
    5
    6
    7
    8
    9
    10
    11
    12
    Worksheet: Tabelle1









    The two files shown above are attatched below:
    Attached Files Attached Files

  7. #147
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    In support of answer to this main excelfox Excel Forum Thread: http://www.excelfox.com/forum/showth...1188#post11188

    Sample file:
    _____ Workbook: MainMacroFile.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    1
    expiry date mark Brand value
    2
    27.06.2019
    a
    1
    3
    26.06.2019
    b
    2
    4
    25.06.2019
    c
    3
    5
    24.06.2019
    d
    4
    6
    23.06.2019
    e
    5
    7
    22.06.2019
    f
    6
    8
    21.06.2019
    g
    7
    9
    20.06.2019
    h
    8
    10
    27.06.2019
    i
    9
    11
    26.06.2019
    j
    10
    12
    13
    Worksheet: Tabelle1


    _____ Workbook: MainMacroFile.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    1
    expiry date mark Brand value
    2
    =TODAY() -(ROW()-3)
    a
    1
    3
    =TODAY() -(ROW()-3)
    b
    2
    4
    =TODAY() -(ROW()-3)
    c
    3
    5
    =TODAY() -(ROW()-3)
    d
    4
    6
    =TODAY() -(ROW()-3)
    e
    5
    7
    =TODAY() -(ROW()-3)
    f
    6
    8
    =TODAY() -(ROW()-3)
    g
    7
    9
    =TODAY() -(ROW()-3)
    h
    8
    10
    27.06.2019
    i
    9
    11
    26.06.2019
    j
    10
    12
    13
    Worksheet: Tabelle1

    Data analysis using VBA arrays
    I personally like to work with VBA arrays. So I put our data into an array, with this code line:
    ThisWorkbook.Worksheets.Item(1).Range("A1").CurrentRegion.Value2
    You can see what is in our arrData() if you step through the coding from within the VB Editor ( Hit key F8 with the cursor in the routine) , then before the run is finished and after the above code line ( Let arrData() ThisWorkbook.Worksheets.Item(1).Range("A1").CurrentRegion.Value2 ) , select any arrData(), and then hit key F9. This will add the array, arrData() to a watch window:
    F9 arrData().JPG: https://imgur.com/02xZas2
    F9 __ arrData().JPG: https://imgur.com/1QKwEb4

    The CurrentRegion
    The CurrentRegion range property of a range ( in this example the range is range A1 ), returns the range connected to that range which can be bordered by either empty columns and rows, or the spreadsheet boundaries. In this example , the CurrentRegion range associated with range A1, is that range enclosed by row 12, column D and the left and top spreadsheet boundaries
    _____ Workbook: MainMacroFile.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    1
    expiry date mark Brand value
    2
    27.06.2019
    a
    1
    3
    26.06.2019
    b
    2
    4
    25.06.2019
    c
    3
    5
    24.06.2019
    d
    4
    6
    23.06.2019
    e
    5
    7
    22.06.2019
    f
    6
    8
    21.06.2019
    g
    7
    9
    20.06.2019
    h
    8
    10
    27.06.2019
    i
    9
    11
    26.06.2019
    j
    10
    12
    13
    Worksheet: Tabelle1

    So this is effectively what our arrData() looks like:
    expiry date mark Brand value
    43643
    a
    1
    43642
    b
    2
    43641
    c
    3
    43640
    d
    4
    43639
    e
    5
    43638
    f
    6
    43637
    g
    7
    43636
    h
    8
    43643
    i
    9
    43642
    j
    10

    So , for example, arrData(5, 2) has a value of d, and arrData(5, 3) value is 4
    Effectively a VBA array is a fixed size spreadsheet, ( usually much smaller than a full spreadsheet ) . You cannot see its contents directly, but you can see it using the Watch Window, as discussed above. It can only have limited infomation - you cannot hold in it things like cell size and color infomation. We are using it to hold the .Value2 . .Value2 is the most fundamental value. .Value2 is usually the simple value that you see in the spreadsheet. One exception to this is with dates. The .Value2 of a date is that number held by Excel internally, which is a whole number starting at 1 for the date of January 1, 1900, and increasing by 1 for every day since then.
    So , for example, the .Value2 of January 5, 1900 is 5
    The .Value2 for the current day as I write this is 43643,which I can see if I step through the routine which is given in the example file , and hover over the variable , DteAujourd_hui , which the coding fills with the whole number part of the current date and time
    43643.jpg : https://imgur.com/mMC42MI
    The exact number you see will likely be slightly different , depending on where you are and when you run the routine
    Attached Files Attached Files

  8. #148
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    In support of this main Forum Thread:
    http://www.excelfox.com/forum/showth...1393#post11393

    Test file: target1.xlsx
    _____ Workbook: target1.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    1
    2
    1
    100
    1
    2
    3
    2
    100
    1
    2
    4
    Worksheet: Tabelle1


    Test file: (Before) target2.xlsx
    _____ Workbook: target2.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    1
    2
    1
    1234
    3
    3
    1234
    4
    Worksheet: Tabelle1


    Now run macro Sub Vixer() , which should fulfil this logic...
    ...If column E of target1.xlsx matches with column A of target2.xlsx then look column O of target1.xlsx is greater or column P of target1.xlsx is greater, whichever is greater calculate the 0.50% of that and multiply that with column K of target1.xlsx and paste the result to target2.xlsx from column C(if column C has data then column D and if column D has data then column E and so on...) the result should be in minus means whatever is the result put minus sign in that along with result

    The main macro file , macro.xlsm , gets populated thus:

    _____ Workbook: macro.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    1
    column A of target2.xlsx column E of target1.xlsx column K of target1.xlsx column O of target1.xlsx column P of target1.xlsx
    2
    1
    1
    100
    1
    2
    3
    3
    2
    100
    1
    2
    4
    Worksheet: Tabelle2


    The test file, target2.xlsx , now gets changed to this
    Test file results After target2.xlsx

    _____ Workbook: target2.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    1
    2
    1
    1234
    -1
    3
    3
    1234
    4
    Worksheet: Tabelle1

    macro_ xlsm from Alan.jpg : https://imgur.com/pyf13dA
    Attachment 2347)
    Attached Images Attached Images
    Attached Files Attached Files

  9. #149
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    In support and appendix for this Thread Post:
    http://www.excelfox.com/forum/showth...1395#post11395
    Data Files from Vixer

    target2.xlsx
    _____ Workbook: target2.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    1
    Symbol
    2
    ACC
    3
    TCS
    4
    MARICO
    5
    M&MFIN
    6
    TATAELXSI
    7
    BAJAJ-AUTO
    8
    BANKBARODA
    9
    10
    11
    12
    Worksheet: Sheet1






    target1.xls
    _____ Workbook: target1.xls ( Using Excel 2007 32 bit )
    Row\Col A B C D E F G H I J K L M N O P Q R S T U V W X Y
    1 UserId AccountId EntityName Exchg-Seg Symbol Instrument Name Option Type NetBuyValue NetSellValue NetValue NetBuyQty NetSellQty NetQty BEP SellAvgPrice BuyAvgPrice LastTradedPrice MarkToMarket Realized MarkToMarket Unrealized MarkToMarket EL MarkToMarket Trading Symbol Client Context Series/Expiry Strike Price
    2 WC5758 NSE MINDTREE EQ 765.00 760.10 -4.90 1 4 760.10 765.00 760.65 -4.9 -4.9 -4.9 MINDTREE-EQ EQ
    3 WC5758 NSE BHEL EQ 135.30 67.65 -67.65 2 4 1 67.65 67.65 67.65 67.5 -0.15 -0.15 -0.15 BHEL-EQ EQ
    4 WC5758 NSE SIEMENS EQ 2540.40 2504.10 -36.30 2 4 1252.05 1270.20 1253 -36.3 -36.3 -36.3 SIEMENS-EQ EQ
    5 WC5758 NSE SUNTV EQ 945.70 939.60 -6.10 2 4 469.80 472.85 473.6 -6.1 -6.1 -6.1 SUNTV-EQ EQ
    Worksheet: ap-Sheet1

    _____ Workbook: target1.xls ( Using Excel 2007 32 bit )
    UserId AccountId EntityName Exchg-Seg Symbol
    WC5758 NSE MINDTREE
    WC5758 NSE BHEL
    WC5758 NSE SIEMENS
    WC5758 NSE SUNTV
    WC5758 NSE RELCAPITAL
    WC5758 NSE JSWSTEEL
    WC5758 NSE TVSMOTOR
    WC5758 NSE RECLTD
    WC5758 NSE PIDILITIND
    WC5758 NSE VOLTAS
    WC5758 NSE TITAN
    WC5758 NSE PNB
    WC5758 NSE OFSS
    WC5758 NSE YESBANK
    WC5758 NSE MFSL
    WC5758 NSE PETRONET
    WC5758 NSE HDFC
    WC5758 NSE PVR
    WC5758 NSE SUNPHARMA
    WC5758 NSE NIITTECH
    WC5758 NSE GRASIM
    WC5758 NSE LICHSGFIN
    WC5758 NSE MANAPPURAM
    WC5758 NSE KAJARIACER
    WC5758 NSE BERGEPAINT
    WC5758 NSE VEDL
    WC5758 NSE UPL
    WC5758 NSE BAJAJFINSV
    WC5758 NSE ULTRACEMCO
    WC5758 NSE UJJIVAN
    WC5758 NSE TATAGLOBAL
    WC5758 NSE TATAELXSI
    WC5758 NSE STAR
    WC5758 NSE SRTRANSFIN
    WC5758 NSE SRF
    WC5758 NSE SAIL
    WC5758 NSE HAVELLS
    WC5758 NSE MCDOWELL-N
    WC5758 NSE PEL
    WC5758 NSE PAGEIND
    WC5758 NSE NMDC
    WC5758 NSE MOTHERSUMI
    WC5758 NSE MARICO
    WC5758 NSE M&MFIN
    WC5758 NSE L&TFH
    WC5758 NSE JUSTDIAL
    WC5758 NSE IGL
    WC5758 NSE IDFCFIRSTB
    WC5758 NSE IDEA
    WC5758 NSE IDBI
    WC5758 NSE HINDZINC
    WC5758 NSE HINDPETRO
    WC5758 NSE GODREJCP
    WC5758 NSE FEDERALBNK
    WC5758 NSE EXIDEIND
    WC5758 NSE ESCORTS
    WC5758 NSE DISHTV
    WC5758 NSE DHFL
    WC5758 NSE CUMMINSIND
    WC5758 NSE CONCOR
    WC5758 NSE COLPAL
    WC5758 NSE CESC
    WC5758 NSE CENTURYTEX
    WC5758 NSE CASTROLIND
    WC5758 NSE CANBK
    WC5758 NSE CADILAHC
    WC5758 NSE BIOCON
    WC5758 NSE BATAINDIA
    WC5758 NSE BANKINDIA
    WC5758 NSE ASHOKLEY
    WC5758 NSE ARVIND
    WC5758 NSE WIPRO
    WC5758 NSE SBIN
    WC5758 NSE APOLLOHOSP
    WC5758 NSE ADANIPOWER
    WC5758 NSE ADANIENT
    WC5758 NSE TECHM
    WC5758 NSE TCS
    WC5758 NSE TATASTEEL
    WC5758 NSE TATAPOWER
    WC5758 NSE RELIANCE
    WC5758 NSE POWERGRID
    WC5758 NSE NTPC
    WC5758 NSE LUPIN
    WC5758 NSE HINDALCO
    WC5758 NSE LT
    WC5758 NSE IOC
    WC5758 NSE INFY
    WC5758 NSE ICICIBANK
    WC5758 NSE IBULHSGFIN
    WC5758 NSE HEROMOTOCO
    WC5758 NSE HCLTECH
    WC5758 NSE GAIL
    WC5758 NSE EICHERMOT
    WC5758 NSE DRREDDY
    WC5758 NSE COALINDIA
    WC5758 NSE BPCL
    WC5758 NSE BOSCHLTD
    WC5758 NSE BHARTIARTL
    WC5758 NSE BANKBARODA
    WC5758 NSE BAJAJ-AUTO
    WC5758 NSE AUROPHARMA
    WC5758 NSE ASIANPAINT
    WC5758 NSE ADANIPORTS
    WC5758 NSE ACC
    Worksheet: ap-Sheet1

  10. #150
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,414
    Rep Power
    10
    Testing for this Thread Post:
    http://www.excelfox.com/forum/showth...ll=1#post11416

    Data Before
    _____ Workbook: ap.xls ( Using Excel 2007 32 bit )
    Row\Col A B C D E F G H I J K L M N O P Q R S T U V W X Y
    1 UserId AccountId EntityName Exchg-Seg Symbol Instrument Name Option Type NetBuyValue NetSellValue NetValue NetBuyQty NetSellQty NetQty BEP SellAvgPrice BuyAvgPrice LastTradedPrice MarkToMarket Realized MarkToMarket Unrealized MarkToMarket EL MarkToMarket Trading Symbol Client Context Series/Expiry
    2 WC5758 NSE MINDTREE EQ ## ## ## 1 4 760.10 765.00 ## -5 -5 -5 MINDTREE-EQ EQ
    3 WC5758 NSE BHEL EQ ## ## ## 2 4 1 ## 67.65 67.65 68 -0 -0 -0 BHEL-EQ EQ
    4 WC5758 NSE SIEMENS EQ ## ## ## 2 4 1252.05 1270.20 ## ## ## ## SIEMENS-EQ EQ
    5 WC5758 NSE SUNTV EQ ## ## ## 2 4 469.80 472.85 ## -6 -6 -6 SUNTV-EQ EQ
    6 WC5758 NSE RELCAPITAL EQ ## ## ## 1 4 58.10 58.50 57 -0 -0 -0 RELCAPITAL-EQ EQ
    7 WC5758 NSE JSWSTEEL EQ ## ## ## 2 4 262.65 263.60 ## -2 -2 -2 JSWSTEEL-EQ EQ
    8 WC5758 NSE TVSMOTOR EQ ## ## ## 1 4 422.30 423.10 ## -1 -1 -1 TVSMOTOR-EQ EQ
    9 WC5758 NSE RECLTD EQ ## ## ## 1 4 138.55 140.50 ## -2 -2 -2 RECLTD-EQ EQ
    10 WC5758 NSE PIDILITIND EQ ## ## ## 1 4 1178.20 1180.00 ## -2 -2 -2 PIDILITIND-EQ EQ
    11 WC5758 NSE VOLTAS EQ ## ## ## 1 4 594.70 595.70 ## -1 -1 -1 VOLTAS-EQ EQ
    12 WC5758 NSE TITAN EQ ## ## ## 1 4 1097.05 1111.00 ## ## ## ## TITAN-EQ EQ
    13 WC5758 NSE PNB EQ ## ## ## 2 4 74.55 74.85 74 -1 -1 -1 PNB-EQ EQ
    14 WC5758 NSE OFSS EQ ## ## ## 2 4 3226.10 3239.95 ## ## ## ## OFSS-EQ EQ
    15
    Worksheet: ap-Sheet1

    Column Y Before ( As above )
    _____ Workbook: ap.xls ( Using Excel 2007 32 bit )
    Row\Col Y
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Worksheet: ap-Sheet1


    Column Y After running routine Sub Vixer3_For_13_data_rows()
    _____ Workbook: ap.xls ( Using Excel 2007 32 bit )
    Row\Col Y
    1
    2 15.3
    3 1.353
    4 25.404
    5 9.457
    6 1.17
    7 5.272
    8 8.462
    9 2.81
    10 23.6
    11 11.914
    12 22.22
    13 1.497
    14 64.799
    Worksheet: ap-Sheet1

    Macro version for 13 data rows
    Code:
    Sub Vixer3_For_13_data_rows() ' http://www.excelfox.com/forum/showthread.php/2352-calculation-and-multiply-by-vba?p=11416&viewfull=1#post11416
    Rem 0 Open data workbook
    ' Workbooks.Open "F:\Excel0202015Jan2016\ExcelFox\vixer\Von Vixer\ap.xls"
    Rem 1 Workbook and worksheets info
    'Dim Wb1 As Workbook: Set Wb1 = Workbooks.Open("F:\Excel0202015Jan2016\ExcelFox\vixer\Von Vixer\ap.xls") '
    Dim Wb1 As Workbook: Set Wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\ap.xls")
    Dim Ws1 As Worksheet: Set Ws1 = Wb1.Worksheets.Item(1) ' First worksheet, (as worksheet object) in open file "sample1.xlsx"
    Dim Lr As Long
     Let Lr = 14 ' To work with 13 data rows
    
    Rem 3 Main Loop for all data rows
    Dim Cnt As Long ' Main Loop for all data rows ================================================
        ' 3a)(i) ' compare column O is greater or column P is greater
        For Cnt = 2 To Lr ' for 13 data rows starting at row 2
        Dim Bigger As Double
            If Ws1.Range("O" & Cnt & "").Value > Ws1.Range("P" & Cnt & "").Value Then ' if column O is greater
             Let Bigger = Ws1.Range("O" & Cnt & "").Value
            Else
             Let Bigger = Ws1.Range("P" & Cnt & "").Value ' if column P is greater
            End If
        '3a)(ii) calculate the 0.50% of that and multiply the same with column L
        Dim Rslt As Double '
         Let Rslt = Bigger * (0.5 / 100) * Ws1.Range("L" & Cnt & "").Value ' calculate the 0.50% of that and multiply the same with column L
        '3b) paste the result to sample1.xlsx column Y
         Let Ws1.Range("Y" & Cnt & "").Value = Rslt
        Next Cnt '     Main Loop for all rows =====================================================
    
    Rem 4 save the changes and close the file
     Wb1.Close savechanges:=True
    End Sub
    Attached Files Attached Files

Similar Threads

  1. Table Tests. And Thread Copy Tests No Reply needed
    By DocAElstein in forum Test Area
    Replies: 1
    Last Post: 11-20-2018, 01:11 PM
  2. Table Tests. And Thread Copy Tests No Reply needed
    By DocAElstein in forum Test Area
    Replies: 1
    Last Post: 11-20-2018, 01:11 PM
  3. Replies: 11
    Last Post: 10-13-2013, 10:53 PM
  4. Replies: 1
    Last Post: 09-14-2013, 12:49 PM
  5. Replies: 7
    Last Post: 08-28-2013, 12:57 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
  •