Page 11 of 30 FirstFirst ... 91011121321 ... LastLast
Results 101 to 110 of 294

Thread: Appendix Thread. ( Codes for other Threads, ( Avinash ).)

  1. #101
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    in support of this Thread:
    http://www.excelfox.com/forum/showth...1472#post11472
    https://www.mrexcel.com/forum/excel-...ation-vba.html
    http://www.vbaexpress.com/forum/show...Formula-by-vba
    http://www.excelforum.com/excel-prog...on-by-vba.html





    _____ Workbook: 124.xlsb ( Using Excel 2007 32 bit )
    Row\Col A B C D E F
    1 Symbol LTP 1st row contains headers so ignore the first row
    2 ACC 1587.95 50 1333.878 Column D is the result that I need by vba
    3 ADANIPORTS 402 70 337.68 I don't want formulas I need only the result in column D
    4 AMBUJACEM 218 20 183.12
    5 ASIANPAINT 1441.3 10 1210.692
    6 AXISBANK 733.65 5 616.266
    7 BANKBARODA 115.25 7 96.81
    8 BHARTIARTL 343.05 8 288.162
    9 BOSCHLTD 15150 19 12726
    10 BPCL 359 350 301.56
    11
    12 Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2
    13 1333.878
    14
    Worksheet: Sheet1

    _____ Workbook: sample.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    E
    12
    Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2
    13
    =B2*(1.5/100)*56
    Worksheet: Sheet1




    Before
    _____ Workbook: 124.xlsb ( Using Excel 2007 32 bit )
    Row\Col A B C D
    2 ACC 1587.95 50
    3 ADANIPORTS 402 70
    4 AMBUJACEM 218 20
    5 ASIANPAINT 1441.3 10
    6 AXISBANK 733.65 5
    7 BANKBARODA 115.25 7
    8 BHARTIARTL 343.05 8
    9 BOSCHLTD 15150 19
    10 BPCL 359 350
    Worksheet: Sheet1

    After
    _____ Workbook: 124.xlsb ( Using Excel 2007 32 bit )
    Row\Col A B C D
    2 ACC 1587.95 50 1333.878
    3 ADANIPORTS 402 70 337.68
    4 AMBUJACEM 218 20 183.12
    5 ASIANPAINT 1441.3 10 1210.692
    6 AXISBANK 733.65 5 616.266
    7 BANKBARODA 115.25 7 96.81
    8 BHARTIARTL 343.05 8 288.162
    9 BOSCHLTD 15150 19 12726
    10 BPCL 359 350 301.56
    Worksheet: Sheet1
    Attached Files Attached Files

  2. #102
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    In support of this Thread:
    http://www.excelfox.com/forum/showthread.php/2369-Calculation-by-vba?p=11472&viewfull=1#post11472
    http://www.excelfox.com/forum/showth...ll=1#post11472


    Quote Originally Posted by sumanjjj View Post
    i have data upto 100 or 200 rows it can be more all it depends i have to do the same process till the end of the data
    So we need to make Lr dynamic, for example
    sample.xlsx
    _____ Workbook: sample.xlsx ( Using Excel 2007 32 bit )
    Row\Col A B C D
    1 Symbol LTP
    2 ACC 1587.95 50
    3 ADANIPORTS 402 70
    4 AMBUJACEM 218 20
    5 ASIANPAINT 1441.3 10
    6 AXISBANK 733.65 5
    7 BANKBARODA 115.25 7
    8 BHARTIARTL 343.05 8
    9 BOSCHLTD 15150 19
    10 BPCL 359 350
    11
    Worksheet: Sheet1



    Code:
    '
    Sub Vixer8b_MakingLrDynamic() ' http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11474&viewfull=1#post11474
    '
    Rem 1 Workbook and worksheets info
    '1a) Workbook info
    Dim Wbm As Workbook: Set Wbm = ThisWorkbook ' The workbook containing macro
    Dim Wb1 As Workbook ' (This will be set later when the workbooks are opened)
    Dim strWb1 As String: Let strWb1 = "sample.xlsx"
    '1b) Worksheets info
    Dim Ws1 As Worksheet ' (This will be set later when the workbooks are opened)
    '                 Dim Lr1 As Long, Lr2 As Long ' To be determined from files                                                                            : Let Lr1 = 7: Lr2 = 6 ' For sample files
    Rem 2 Open file   .....
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & strWb1
     Set Wb1 = ActiveWorkbook ' The workbook just opened will now be the current active workbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    
    
    Rem 3 making Lr dynamic
    Dim Lr1 As Long
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
     Let Lr1 = Ws1.Cells.Item(Ws1.Rows.Count, 3).End(xlUp).Row
     Let Lr1 = Ws1.Cells.Item(Ws1.Rows.Count, "C").End(xlUp).Row
    
    '3b)(i) demo (i)
     Ws1.Activate
     MsgBox prompt:="Lr in worksheet " & Ws1.Name & ", in workbook " & Wb1.Name & " is   " & Lr1 & vbCrLf & "(last row in worksheet is   " & Ws1.Rows.Count & ")"
    
    '3b)(ii) demo (ii)
     Ws1.Range("C" & Ws1.Rows.Count).Select ' select last cell in column C
     Application.Wait (Now + TimeValue("0:00:03"))  '  VBA wait 3 seconds    https://docs.microsoft.com/de-de/office/vba/api/excel.application.wait
    
     ActiveCell.End(xlUp).Select            ' go back up to last used cell in column C
     Application.Wait (Now + TimeValue("0:00:06"))  '  VBA wait 6 seconds
    
    Rem 4 close file
     Wb1.Close
    End Sub


    Code:
    Rem 3 making Lr dynamic
    Dim Lr1 As Long
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
     Let Lr1 = Ws1.Cells.Item(Ws1.Rows.Count, 3).End(xlUp).Row
     Let Lr1 = Ws1.Cells.Item(Ws1.Rows.Count, "C").End(xlUp).Row

    To explain:-

    _ Rows.Count
    Ws1.Range("C" & Ws1.Rows.Count)
    Or
    Ws1.Cells.Item(Ws1.Rows.Count, 3)
    Or
    Ws1.Cells.Item(Ws1.Rows.Count, "C")


    We are in a .xlsx file, so Rows.Count is 1048576
    Ws1.Range("C" & 1048576)
    or
    Ws1.Cells.Item(1048576, 3)
    or
    Ws1.Cells.Item(1048576, "C")


    This is the last cell in column C:
    Last cell in Column C in worksheet Sheet1 in workbook sample xlsx.JPG : https://imgur.com/HH9UKki
    Attachment 2413
    _____ Workbook: sample.xlsx ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    1048574
    1048575
    1048576
    Worksheet: Sheet1

    So we are at the bottom of the worksheet…..

    _ .End(XlUp) Property action
    This is the same as keyboard keys _ Ctrl+UpArrow
    Ctrl + UpArrow.JPG : https://imgur.com/w5w8KxZ
    Attachment 2402

    …This action will take you back up to the next filled cell:
    _End(XlUp) in column C from last cell in worksheet Sheet1 in workbook sample xlsx : https://imgur.com/fIDDbYB
    Attachment 2411

    …so we are at the last cell in column C that is filled with something

    _ .Row Property
    This will return the row number or the cell to which it is applied.
    _Row for current active cell.JPG : https://imgur.com/uKVAIgN
    Attachment 2412

  3. #103
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    Some further notes and information for this Thread:
    http://www.excelfox.com/forum/showth...1476#post11476
    http://www.excelfox.com/forum/showth...ulation-by-vba
    https://www.mrexcel.com/forum/excel-...ation-vba.html
    http://www.vbaexpress.com/forum/show...Formula-by-vba
    https://www.excelforum.com/excel-pro...on-by-vba.html


    There are many different was to achieve the same…
    Some further notes on changes that can be made to Sub Vixer9a() from here: http://www.excelfox.com/forum/showth...ll=1#post11475




    b) Rng.Value = Rng.Value

    Excel VBA has been written such that applying .Value to a cell or cells has a similar effect to writing manually into a cell.

    So if you do this:
    Range("A1").Value = "X"
    , it will write
    X
    in the first cell.
    You will then see in the first cell this
    X

    If you do this:
    Range("A1").Value = " = 1"
    , it will write
    = 1
    in the first cell.
    But, you will see in the first cell just the Value:
    1

    To explain:
    The .Value Property of a range object , for example a single cell, is what we "see" in the cell. But if you apply .Value to a cell it will write into the cell as if you did it manually.

    So, in your code you can replace this: …_
    Code:
    '3(iii) I need only result in the cell no formulas
     Ws1.Range("D2:D" & Lr1 & "").Copy
     Ws1.Range("D2:D" & Lr1 & "").PasteSpecial Paste:=xlPasteValues
     Let Application.CutCopyMode = False
    _.. with this:
    Code:
    '3(iii) I need only result in the cell no formulas
     Let Ws1.Range("D2:D" & Lr1 & "").Value = Ws1.Range("D2:D" & Lr1 & "").Value

    Code:
    Sub Vixer9b() ' demo for   rng.Value = rng.Value
    Rem 1 Workbook and worksheets info
    '1a) Workbook info
    ' Dim Wbm As Workbook: Set Wbm = ThisWorkbook ' The workbook containing macro
    Dim Wb1 As Workbook ' This will be set later when the workbook is opened
    Dim MyPath As String: Let MyPath = "C:\Users\sk\Desktop" '  ".....The file will be located in C:\Users\sk\Desktop ....
    Dim strWb1 As String: Let strWb1 = "sample.xlsx" '                                                          " ....and file name is sample.xlsx
    '1b) Worksheets info
    Dim Ws1 As Worksheet ' This will be set later when the workbook is opened)
    Dim Lr1 As Long '      Let Lr1 = 10 for sample file  , but we will determine it dynamically after opening the file
    Rem 2 Open file   "..... file is not opened so we have to open the file by vba
    ' Workbooks.Open Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\sample.xlsx"
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & strWb1  '  ...both files are located in same place
    ' Workbooks.Open Filename:=MyPath & "\" & strWb1              '  ...file will be located in C:\Users\sk\Desktop
     Set Wb1 = ActiveWorkbook ' The workbook just opened will now be the current active workbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    ' make Lr1 dynamic .... http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11474&viewfull=1#post11474
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
    Rem 3 The Process ..."....
    '3(i) ....Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2.. formula will be added by me in the code, put that formula in
     Ws1.Range("D2").Value = "=B2*(1.5/100)*56"
    '3(ii) ....drag it
     Ws1.Range("D2").AutoFill Destination:=Ws1.Range("D2:D" & Lr1 & ""), Type:=xlFillDefault
    '3(iii) I need only result in the cell no formulas
     Let Ws1.Range("D2:D" & Lr1 & "").Value = Ws1.Range("D2:D" & Lr1 & "").Value
    Rem 4 save it and close it
     Wb1.Save
     Wb1.Close
    End Sub




    _c) Apply "fixed vector"** form across a range

    I can apply the formula in its "fixed vector"** form across a range. In other words I can apply the same formula in its fixed vector form across a range. Applying the same fixed vector formula across a range will make any referred to cells change the shown formula appropriately to apply to the different cells

    ** In simplified terms, "fixed vector", means notation without the $. So..
    A1 is "fixed vector"
    $A$1 is absolute referencing

    So we can replace this:
    Code:
    '3(i) ....Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2.. formula will be added by me in the code, put that formula in
     Ws1.Range("D2").Value = "=B2*(1.5/100)*56"
    '3(ii) ....drag it
     Ws1.Range("D2").AutoFill Destination:=Ws1.Range("D2:D" & Lr1 & ""), Type:=xlFillDefault
    With this:
    Code:
    '3(i)(ii) ....Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2..   ....drag it formula will be added by me in the code, put that formula in
     Ws1.Range("D2:D" & Lr1 & "").Value = "=B2*(1.5/100)*56"
    Code:
    Sub Vixer9c() ' demo for   fixed vector applied across a range
    Rem 1 Workbook and worksheets info
    '1a) Workbook info
    ' Dim Wbm As Workbook: Set Wbm = ThisWorkbook ' The workbook containing macro
    Dim Wb1 As Workbook ' This will be set later when the workbook is opened
    Dim MyPath As String: Let MyPath = "C:\Users\sk\Desktop" '  ".....The file will be located in C:\Users\sk\Desktop ....
    Dim strWb1 As String: Let strWb1 = "sample.xlsx" '                                                          " ....and file name is sample.xlsx
    '1b) Worksheets info
    Dim Ws1 As Worksheet ' This will be set later when the workbook is opened)
    Dim Lr1 As Long '      Let Lr1 = 10 for sample file  , but we will determine it dynamically after opening the file
    Rem 2 Open file   "..... file is not opened so we have to open the file by vba
    ' Workbooks.Open Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\sample.xlsx"
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & strWb1  '  ...both files are located in same place
    ' Workbooks.Open Filename:=MyPath & "\" & strWb1              '  ...file will be located in C:\Users\sk\Desktop
     Set Wb1 = ActiveWorkbook ' The workbook just opened will now be the current active workbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    ' make Lr1 dynamic .... http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11474&viewfull=1#post11474
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
    Rem 3 The Process ..."....
    '3(i)(ii) ....Multiply the value of B2 by 1.5%, then multiply that result by 56 and then paste the result in D2..   ....drag it formula will be added by me in the code, put that formula in
     Ws1.Range("D2:D" & Lr1 & "").Value = "=B2*(1.5/100)*56"
    '3(iii) I need only result in the cell no formulas
     Let Ws1.Range("D2:D" & Lr1 & "").Value = Ws1.Range("D2:D" & Lr1 & "").Value
    Rem 4 save it and close it
     Wb1.Save
     Wb1.Close
    End Sub





    _d) Internal calculation with VBA arrays
    We do not need to put formulas into any cells.
    We can do the calculations internally, within coding, and then paste all the values out in one go.
    Using VBA arrays is a convenient way to do this.

    _a) First we bring all the data into an array.
    _b) Then we do the calculations
    _c) Finally we paste out all the calculated values in one go

    We can replace all of Rem3 with new coding
    Rem 3 The Process .. using VBA arrays
    '3_a) First we bring all the data into an array.
    '3_b) Now we do the calculations
    '3_c) Finally we paste out all the calculated values in one go

    Code:
    Rem 3 The Process ...using VBA arrays
    '3_a) First we bring all the data into an array. (We also take in the column D values, even if the column D is empty)
    Dim arrDta() As Variant
     Let arrDta() = Ws1.Range("A1:D" & Lr1 & "").Value
    '3_b) Now we do the calculations looping through the row data held internally in the data array, arrDta()
    Dim Cnt As Long
        For Cnt = 2 To Lr1
         Let arrDta(Cnt, 4) = arrDta(Cnt, 2) * (1.5 / 100) * 56 ' .. like.. column "D" = column "B" * (1.5/100) * 56
        Next Cnt
    '3_c) Finally we paste out all the calculated values ( and also the original data )  in one go
     Ws1.Range("A1:D" & Lr1 & "").Value = arrDta()
    Code:
    Sub Vixer9d() ' demo using VBA arrays
    Rem 1 Workbook and worksheets info
    '1a) Workbook info
    ' Dim Wbm As Workbook: Set Wbm = ThisWorkbook ' The workbook containing macro
    Dim Wb1 As Workbook ' This will be set later when the workbook is opened
    Dim MyPath As String: Let MyPath = "C:\Users\sk\Desktop" '  ".....The file will be located in C:\Users\sk\Desktop ....
    Dim strWb1 As String: Let strWb1 = "sample.xlsx" '                                                          " ....and file name is sample.xlsx
    '1b) Worksheets info
    Dim Ws1 As Worksheet ' This will be set later when the workbook is opened)
    Dim Lr1 As Long '      Let Lr1 = 10 for sample file  , but we will determine it dynamically after opening the file
    Rem 2 Open file   "..... file is not opened so we have to open the file by vba
    ' Workbooks.Open Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\sample.xlsx"
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & strWb1  '  ...both files are located in same place
    ' Workbooks.Open Filename:=MyPath & "\" & strWb1              '  ...file will be located in C:\Users\sk\Desktop
     Set Wb1 = ActiveWorkbook ' The workbook just opened will now be the current active workbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    ' make Lr1 dynamic .... http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11474&viewfull=1#post11474
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
    Rem 3 The Process ...using VBA arrays
    '3_a) First we bring all the data into an array. (We also take in the column D values, even if the column D is empty)
    Dim arrDta() As Variant
     Let arrDta() = Ws1.Range("A1:D" & Lr1 & "").Value
    '3_b) Now we do the calculations looping through the row data held internally in the data array, arrDta()
    Dim Cnt As Long
        For Cnt = 2 To Lr1
         Let arrDta(Cnt, 4) = arrDta(Cnt, 2) * (1.5 / 100) * 56 ' .. like.. column "D" = column "B" * (1.5/100) * 56
        Next Cnt
    '3_c) Finally we paste out all the calculated values ( and also the original data )  in one go
     Ws1.Range("A1:D" & Lr1 & "").Value = arrDta()
    Rem 4 save it and close it
     Wb1.Save
     Wb1.Close
    End Sub




    _e) Evaluate Range
    see next post:

  4. #104
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10

    e) Evaluate Range

    _e) Evaluate Range

    It is possible to get array type calculations in Excel. Nobody fully understands this topic, and a lot of things are found by chance to work in a way such as to do array type calculations, or rather , array type results can be obtained.

    Evaluate Range techniques often allow a looping process to be replaced ba a single line of code. Broadly this arises due to two things:
    _1) Excel frequently updates all cells in a spreadsheet by going across the columns in a row , then down a row, then across the columns in the next row … etc.
    Usually a user "using" a single cell is like when it selected, and/ or the carriage Return key is used, and so it appears to us as if the cell is Updated and displayed at one time. There are various ways to display more than one cell in a single spreadsheet update.
    _2) In VBA there is an Evaluate Method ( https://docs.microsoft.com/en-us/off...ation.evaluate ). In simplified terms, this allows calculation within VBA as if the calculations were written and done in a spreadsheet.

    It is possible sometimes to get the Evaluate function to return an array representing the calculations across a range
    There is no clear documentation on any of the array type things discussed in this post, and it is often suggested that getting array results in any form in Excel has occurred by chance and no one understands fully what is going on.


    As an example, considering the last macro which looped to produce an array based on doing these calculations of this form, from down rows of 2 to Lr1
    B2*(1.5/100)*56
    B3*(1.5/100)*56
    B4*(1.5/100)*56

    _…. etc.

    We find that Rem 3 from the last macro, Sub Vixer9d() , can be replaced by
    Code:
    Rem 3 The Process ...   using Evaluate Range
     Ws1.Range("D2:D" & Lr1 & "").Value = Ws1.Evaluate("=" & Range("B2:B" & Lr1 & "").Address & "*(1.5/100)*56")

    The purpose of ("=" & Range("B2:B" & Lr1 & "") is to give us the formula form of like
    =B2:B10
    Hence the Range used does not need to be Qualified, such as by a worksheet, like in Ws1.Range
    ( There is an alternative form of Evaluate(" __ ") , which is often referred to as the "shorthand form" of Evaluate(" __ ") . It looks like this _ [ ___ ] _ . So you may now see what Mark L was suggesting here: https://www.excelforum.com/excel-pro...ml#post5190685 )

    It is , however , important to qualify Evaluate. this is because we want to do an evaluation as if the formula within Evaluate(" ___ ") , was in the cell in worksheet, Ws1. If we omit the qualifying _ Ws1. _ , before the Evaluate , then we may do an evaluation of the formula in a different worksheet.


    Code:
    Sub Vixer9e() ' demo  for  Evaluate Range
    Rem 1 Workbook and worksheets info
    '1a) Workbook info
    ' Dim Wbm As Workbook: Set Wbm = ThisWorkbook ' The workbook containing macro
    Dim Wb1 As Workbook ' This will be set later when the workbook is opened
    Dim MyPath As String: Let MyPath = "C:\Users\sk\Desktop" '  ".....The file will be located in C:\Users\sk\Desktop ....
    Dim strWb1 As String: Let strWb1 = "sample.xlsx" '                                                          " ....and file name is sample.xlsx
    '1b) Worksheets info
    Dim Ws1 As Worksheet ' This will be set later when the workbook is opened)
    Dim Lr1 As Long '      Let Lr1 = 10 for sample file  , but we will determine it dynamically after opening the file
    Rem 2 Open file   "..... file is not opened so we have to open the file by vba
    ' Workbooks.Open Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\sample.xlsx"
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & strWb1  '  ...both files are located in same place
    ' Workbooks.Open Filename:=MyPath & "\" & strWb1              '  ...file will be located in C:\Users\sk\Desktop
     Set Wb1 = ActiveWorkbook ' The workbook just opened will now be the current active workbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    ' make Lr1 dynamic .... http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11474&viewfull=1#post11474
     Let Lr1 = Ws1.Range("C" & Ws1.Rows.Count).End(xlUp).Row
    Rem 3 The Process ...   using Evaluate Range
     Ws1.Range("D2:D" & Lr1 & "").Value = Ws1.Evaluate("=" & Range("B2:B" & Lr1 & "").Address & "*(1.5/100)*56")
    Rem 4 save it and close it
     Wb1.Save
     Wb1.Close
    End Sub






    Using Evaluate often results in a much shorter coding.

    For example, taking Sub Vixer9e() , and making a few other simplifications we can come up with a much shorter coding.


    Code:
    Sub Vixer9f() ' simplified coding ( using Range Evaluate )
     Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "sample.xlsx"  '  ...both files are located in same place
    Rem 3 The Process ...   using Evaluate Range
     ActiveSheet.Range("D2:D" & ActiveSheet.Range("C" & ActiveSheet.Rows.Count).End(xlUp).Row & "").Value = ActiveSheet.Evaluate("=" & Range("B2:B" & ActiveSheet.Range("C" & ActiveSheet.Rows.Count).End(xlUp).Row & "").Address & "*(1.5/100)*56")
    Rem 4 save it and close it
     ActiveWorkbook.Close savechanges:=True
    End Sub





    I personally do not like such coding because
    _(i) They are more difficult to understand, especially at a later date,
    _(ii) They are less flexible for adjustment.
    _(iii) There may be some missing detail which might cause the coding to fail sometimes in certain circumstances
    Attached Files Attached Files

  5. #105
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    in support of this post:
    https://excel.tips.net/T001940_Hidin...ell_Value.html
    https://excel.tips.net/T001940_Hiding_Rows_Based_on_a_Cell_Value.html



    Hello Ryanne
    Rather than modifying the coding, it would probably be easier to use a simple "events" type coding which automatically kicks in when a range value is changed in a worksheet. Something of this form:.

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
     Target.EntireRow.Hidden = True
    End Sub
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    '
    'End Sub
    This coding will need to be in a worksheet code module.
    Follow , for example these 6 steps to create such a coding:

    _1) Right click on the tab of the worksheet of interest
    _2) Select View Code
    Worksheet code module via View Code after right click on tab.JPG : : https://imgur.com/ZiOuRVT
    Attachment 2426

    _3) Select the left side drop down list
    _4) Select Worksheet
    Worksheet.JPG : https://imgur.com/tCwHKBo
    Attachment 2427

    _5) Select the right drop down list
    _6) Select Change
    Change.JPG : https://imgur.com/NkbNPsL
    Attachment 2428

    ( Delete or ' comment out any other coding, such as the Private Sub Worksheet_SelectionChange which may have appeared automatically at step 4 )



    You can now add your coding within the Private Sub Worksheet_Change


    ( Hit Alt+F11 to return to spreadsheet view )

    The coding will kick off automatically when you change any cell value. It will hide the entire row which contains the cell whose value you changed


    In the uploaded file , I have added the coding to the third worksheet code module

    Alan
    Attached Images Attached Images
    Attached Files Attached Files

  6. #106
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    Some supporting notes for some other stuff...



    _3) Regarding the remaining leftover hide.me app on Windows 7 machine after I de- installed it
    ….( hide.me that was still showing in my program list after I had de installed, and note also that on restarting the windows 7 machine with the remaining left over hideme app, a hideme typically window came up , did something for a while, then another hide me window came up and offered me the chance to buy premium!! )
    Strange remaining hide me thing after de install.JPG : https://imgur.com/4HsLmDN
    Attachment 2439

    I tried the Revo Unistaller as suggested, http://revo-uninstaller.en.softonic.com/ .
    This was also not able to de install the hide.me that was still showing in my program list after I had de installed it: Revo also cannot de install the remaining hide.me.jpghttps://imgur.com/HY7pSIy
    After this failed attempt, I performed the scan that Revo offered.
    This scan took several hours. The scan first showed these left over registry things, Revo scan found left over hideme.jpg : https://imgur.com/r99WKN6
    Attachment 2440
    , which I chose to delete: Choose to delete found left over hideme.jpg , Deleting scan found left over hideme.jpg : https://imgur.com/aoToZJ2 , https://imgur.com/5jsACjQ .
    Then the following left over files and folders were also shown, Revo scan found left over hideme Files and Folders.jpg : https://imgur.com/78YKmd4
    Attachment 2441
    , which I also chose to delete: Choose to delete Revo scan found left over hideme Files and Folders.jpg , Deletingf Revo scan found left over hideme Files and Folders.jpg : https://imgur.com/VAlBzED , https://imgur.com/2YoSSML .
    Finally it appears that all left over hide.me files are gone: hideme no longer listed in programs.jpg : https://imgur.com/9aentWL
    A restart is said to remove some files, .. Revo says remainig files will be deleted by restart.jpg : https://imgur.com/QTjDtf1 , so I restarted.
    It seemed at this stage, ( after a restart) that the hideme app was completely removed.

  7. #107
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    In support of answers to these Threads:
    http://www.excelfox.com/forum/showth...ified-email-id
    https://stackoverflow.com/questions/...75857_58525487
    https://stackoverflow.com/questions/...-be-sent-to-sm
    https://stackoverflow.com/questions/...-less-and-less






    Register an account with Freemail German Telekom, for use with CDO.Message Send program

    Login / Register

    https://www.t-online.de/
    Login.JPG : https://imgur.com/n5aLakd
    https://accounts.login.idm.telekom.c...nse_type=code#
    ht[color==#417394]tps://accounts.login.idm.telekom.com/oauth2/auth?client_id=10LIVESAM30000004901PORTAL000000000 00000&state=d725154dc1fc296807eda1341546636892fc9739ccb7 5d714dc2c89b4159148e&claims=%7B%22id_token%22%3A%7B%22urn%3Atelekom.com %3Aall%22%3Anull%7D%7D&nonce=d725154dc1fc296807eda1341546636892fc9739ccb7 5d714dc2c89b4159148e&redirect_uri=https%3A%2F%2Flogin.t-online.de%2Fcallback&display=popup&scope=openid&response_type=code#[/color]

    Registrieren.JPG : https://imgur.com/J6nnDm2
    https://meinkonto.telekom-dienste.de...nt/index.xhtml
    https://meinkonto.telekom-dienste.de...erstatus.xhtml

    UserStatus.jpg : https://imgur.com/IqjhWop

    New Email Address
    New Email Address.jpg : https://imgur.com/zH2G73c

    Register
    Register.JPG : https://imgur.com/570UkbH
    https://imgur.com/D6vRwex
    You will probably be sent a number code via SMS to your Telephine number. , https://imgur.com/eBpabq5 ,

  8. #108
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    In support to answer of this Thread:
    http://www.excelfox.com/forum/showth...ll=1#post11557

    _____ Workbook: VBA.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    1234
    2
    5678
    3
    91011
    4
    12131415
    5
    1617181920
    Worksheet: abc
    'match column A of abc sheet with column A of def sheet
    ' if it matches then delete that data in column A of def
    ' "match column A of abc sheet with column A of def sheet if it matches then delete that data in column A of def"

    _____ Workbook: VBA.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    1
    1234
    2
    15678
    3
    191011
    4
    112131415
    5
    16171811920
    after the process completed delete all the data in this sheet
    Worksheet: def
    _____ Workbook: VBA Exampled.xls ( Using Excel 2007 32 bit )
    15678
    191011
    112131415
    16171811920
    Worksheet: def
    _____ Workbook: VBA Exampled.xls ( Using Excel 2007 32 bit )



    'and the data which are not matched compare that data ( here 'that data' means unmatched data in abc. Right? ) with Fake Data and
    ' if matched then delete and again if there will be unmatched data ( here also 'unmatched data' means unmatched data in abc. Right? ) then

    _____ Workbook: VBA.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    115678
    2
    191011
    3
    1112131415
    4
    1.16172E+11
    Worksheet: Fake Data
    _____ Workbook: VBA Exampled.xls ( Using Excel 2007 32 bit )

    15678
    112131415
    16171811920
    Worksheet: def
    115678
    1112131415
    1.16172E+11
    Worksheet: Fake Data



    '................................................. ...................if there will be unmatched data then
    ' compare that data with complete data

    _____ Workbook: VBA.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    115678
    2
    Worksheet: Completed
    ' if found then delete and again if there will be unmatched data
    1112131415
    1.16172E+11
    Worksheet: Fake Data
    then
    ' copy that data and paste it to missing data sheet in column A ( and finally delete all the data in def : after the process completed delete all the data in this sheet )

    Quote Originally Posted by fixer View Post
    the final result is in missing data sheet plz see
    missing data sheet already has data and we have pasted the result below that data(the data starts with A2 is the result)
    A1 in missing data sheet already has data so we putted the result below that plz see sir
    ....in simple words with def sheet the data which are present in column A doesnt match with any sheet column A data then put that data in missing data sheet sir (sheet can be many)
    _____ Workbook: VBA.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    11111158
    2
    1112131415
    3
    1.16172E+11
    4
    Worksheet: Missing data
    _____ Workbook: VBA Exampled.xls ( Using Excel 2007 32 bit )
    11111158
    1112131415
    1.16172E+11
    Worksheet: Missing data

  9. #109
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    follow on from last post:

    Before
    Quote Originally Posted by fixer View Post
    the final result is in missing data sheet plz see
    missing data sheet already has data and we have pasted the result below that data(the data starts with A2 is the result)
    A1 in missing data sheet already has data so we putted the result below that plz see sir
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    11111158
    2
    3
    4
    Worksheet: Missing data
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    1234
    2
    5678
    3
    91011
    4
    12131415
    5
    1617181920
    6
    Worksheet: abc
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    1
    1234
    2
    15678
    3
    191011
    4
    112131415
    5
    16171811920
    after the process completed delete all the data in this sheet
    Worksheet: def
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    115678
    2
    191011
    3
    1112131415
    4
    1.16172E+11
    5
    Worksheet: Fake Data
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    115678
    2
    Worksheet: Completed
    _____ Workbook: VBA Before.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    11111158
    2
    3
    4
    Worksheet: Missing data
    Attached Files Attached Files

  10. #110
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10
    Follow on from last 2 posts





    Explanation attempt
    Column A of worksheet abc is compared with column A of worksheet def, looking for matches in data. If data in Column A of worksheet def is also found in column A of worksheet abc, then that matched data in column A of worksheet def is deleted
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    1234
    2
    5678
    3
    91011
    4
    12131415
    5
    1617181920
    6
    Worksheet: abc
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    1234
    2
    15678
    3
    191011
    4
    112131415
    5
    16171811920
    Worksheet: def
    Column A of worksheet abc is compared with column A of worksheet def, looking for matches in data. If data in Column A of worksheet def is also found in column A of worksheet abc, then that matched data in column A of worksheet def is deleted
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    1234
    15678
    191011
    112131415
    16171811920
    Worksheet: def (modified)


    The remain data in worksheet def is now compared with column A of worksheet Fake Data.
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    115678
    2
    191011
    3
    1112131415
    4
    1.16172E+11
    5
    Worksheet: Fake Data
    If data in Column A of worksheet Fake Data is also found in column A of the modified worksheet def, then that matched data in column A of worksheet Fake Data is deleted
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    115678
    191011
    1112131415
    1.16172E+11
    Worksheet: Fake Data (modified)

    The remaining data in column A of modified worksheet Fake Data is now compared with column A of worksheet Completed
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    115678
    2
    Worksheet: Completed
    If there is a match in data in columns A of worksheet Completed, and column A of worksheet Fake Data, then delete that matched data from worksheet Fake Data
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    115678
    191011
    1112131415
    1.16172E+11
    Worksheet: Fake Data (modified)

    If there is now any remaining data in column A of modified Fake Data, then that data is added to column A of missing data , ( in the given example, VBA Before.xls , A1 in missing data sheet already had data
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    11111158
    2
    Worksheet: Missing data
    so we put the result below that:
    _____ Workbook: VBA worked excample.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    1
    11111158
    2
    1112131415
    3
    1.16172E+11
    4
    Worksheet: Missing data (final)
    Attached Files Attached Files

Similar Threads

  1. Replies: 185
    Last Post: 05-22-2024, 10:02 PM
  2. Tests and Notes for EMail Threads
    By DocAElstein in forum Test Area
    Replies: 29
    Last Post: 11-15-2022, 04:39 PM
  3. Replies: 379
    Last Post: 11-13-2020, 07:44 PM
  4. Appendix Thread. Diet Protokol Coding Adaptions
    By DocAElstein in forum Test Area
    Replies: 6
    Last Post: 09-05-2019, 10:45 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
  •