Automate copy paste Excel ranges dynamically from different sheets












0















I have tables in different sheets of excel and requirement is to copy second last row of table to last row. Can someone pls help me how can we dynamically find table size so that code wont be required to change evrytime when table size changes? There are many tables and we want to automate this task using vba code and macro button.



I have written a code but that is range specific and everytime I need to update the range and process become cumbersome.



Sub history_copy()

Set obj = ActiveWorkbook.Sheets("sheet A")
obj.Range("E12:N12").Value = obj.Range("E11:N11").Value
obj.Range("E34:N34").Value = obj.Range("E33:N33").Value
obj.Range("E46:N46").Value = obj.Range("E45:N45").Value
obj.Range("E57:N57").Value = obj.Range("E56:N56").Value

Set obj1 = ActiveWorkbook.Sheets("sheet b ")
obj1.Range("G21:O21").Value = obj1.Range("G20:O20").Value

Set obj2 = ActiveWorkbook.Sheets("sheet c")
obj2.Range("D4:M4").Value = obj2.Range("D3:M3").Value
obj2.Range("D14:M14").Value = obj2.Range("D13:M13").Value
obj2.Range("D23:M23").Value = obj2.Range("D22:M22").Value
obj2.Range("D33:M33").Value = obj2.Range("D32:M32").Value
obj2.Range("D43:M43").Value = obj2.Range("D42:M42").Value
obj2.Range("D52:M52").Value = obj2.Range("D51:M51").Value
obj2.Range("D61:M61").Value = obj2.Range("D60:M60").Value
obj2.Range("D70:M70").Value = obj2.Range("D69:M69").Value
obj2.Range("D79:M79").Value = obj2.Range("D78:M78").Value
obj2.Range("D88:M88").Value = obj2.Range("D87:M87").Value
obj2.Range("D97:M97").Value = obj2.Range("D96:M96").Value
obj2.Range("D106:M106").Value = obj2.Range("D105:M105").Value
obj2.Range("D114:M114").Value = obj2.Range("D113:M113").Value

Set obj3 = ActiveWorkbook.Sheets("sheet d")
obj3.Range("D4:L4").Value = obj3.Range("D3:L3").Value



Set obj5 = ActiveWorkbook.Sheets("sheet f")
obj5.Range("D4:L4").Value = obj5.Range("D3:L3").Value

Set obj6 = ActiveWorkbook.Sheets("sheet e")
obj6.Range("C4:C12").Value = obj6.Range("B4:B12").Value
obj6.Range("H4:H8").Value = obj6.Range("G4:G8").Value
obj6.Range("N4:N11").Value = obj6.Range("M4:M11").Value
obj6.Range("S4:S10").Value = obj6.Range("R4:R10").Value
obj6.Range("X4:X18").Value = obj6.Range("W4:W18").Value
obj6.Range("AD4:AD9").Value = obj6.Range("AC4:AC9").Value
obj6.Range("AI4:AI13").Value = obj6.Range("AH4:AH13").Value
obj6.Range("AO4:AO6").Value = obj6.Range("AN4:AN6").Value
obj6.Range("AT4:AT11").Value = obj6.Range("AS4:AS11").Value
obj6.Range("AY4:AY20").Value = obj6.Range("AX4:AX20").Value
obj6.Range("BD4:BD10").Value = obj6.Range("BC4:BC10").Value
obj6.Range("BI4:BI21").Value = obj6.Range("BH4:BH21").Value

Set obj7 = ActiveWorkbook.Sheets("sheet i")
obj7.Range("C4:C12").Value = obj7.Range("B4:B12").Value
obj7.Range("H4:H8").Value = obj7.Range("G4:G8").Value
obj7.Range("N4:N11").Value = obj7.Range("M4:M11").Value
obj7.Range("S4:S10").Value = obj7.Range("R4:R10").Value
obj7.Range("X4:X18").Value = obj7.Range("W4:W18").Value
obj7.Range("AD4:AD9").Value = obj7.Range("AC4:AC9").Value
obj7.Range("AI4:AI13").Value = obj7.Range("AH4:AH13").Value
obj7.Range("AO4:AO6").Value = obj7.Range("AN4:AN6").Value
obj7.Range("AT4:AT11").Value = obj7.Range("AS4:AS11").Value
obj7.Range("AY4:AY20").Value = obj7.Range("AX4:AX20").Value
obj7.Range("BD4:BD10").Value = obj7.Range("BC4:BC10").Value
obj7.Range("BI4:BI21").Value = obj7.Range("BH4:BH21").Value


End Sub









share|improve this question

























  • Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

    – teylyn
    Nov 14 '18 at 6:33











  • Thanks for your reply. I have now posted my code in question. Can you please now help me.

    – user824565
    Nov 14 '18 at 6:43











  • What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

    – teylyn
    Nov 14 '18 at 6:51













  • we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

    – user824565
    Nov 14 '18 at 7:52






  • 1





    Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

    – teylyn
    Nov 14 '18 at 8:35


















0















I have tables in different sheets of excel and requirement is to copy second last row of table to last row. Can someone pls help me how can we dynamically find table size so that code wont be required to change evrytime when table size changes? There are many tables and we want to automate this task using vba code and macro button.



I have written a code but that is range specific and everytime I need to update the range and process become cumbersome.



Sub history_copy()

Set obj = ActiveWorkbook.Sheets("sheet A")
obj.Range("E12:N12").Value = obj.Range("E11:N11").Value
obj.Range("E34:N34").Value = obj.Range("E33:N33").Value
obj.Range("E46:N46").Value = obj.Range("E45:N45").Value
obj.Range("E57:N57").Value = obj.Range("E56:N56").Value

Set obj1 = ActiveWorkbook.Sheets("sheet b ")
obj1.Range("G21:O21").Value = obj1.Range("G20:O20").Value

Set obj2 = ActiveWorkbook.Sheets("sheet c")
obj2.Range("D4:M4").Value = obj2.Range("D3:M3").Value
obj2.Range("D14:M14").Value = obj2.Range("D13:M13").Value
obj2.Range("D23:M23").Value = obj2.Range("D22:M22").Value
obj2.Range("D33:M33").Value = obj2.Range("D32:M32").Value
obj2.Range("D43:M43").Value = obj2.Range("D42:M42").Value
obj2.Range("D52:M52").Value = obj2.Range("D51:M51").Value
obj2.Range("D61:M61").Value = obj2.Range("D60:M60").Value
obj2.Range("D70:M70").Value = obj2.Range("D69:M69").Value
obj2.Range("D79:M79").Value = obj2.Range("D78:M78").Value
obj2.Range("D88:M88").Value = obj2.Range("D87:M87").Value
obj2.Range("D97:M97").Value = obj2.Range("D96:M96").Value
obj2.Range("D106:M106").Value = obj2.Range("D105:M105").Value
obj2.Range("D114:M114").Value = obj2.Range("D113:M113").Value

Set obj3 = ActiveWorkbook.Sheets("sheet d")
obj3.Range("D4:L4").Value = obj3.Range("D3:L3").Value



Set obj5 = ActiveWorkbook.Sheets("sheet f")
obj5.Range("D4:L4").Value = obj5.Range("D3:L3").Value

Set obj6 = ActiveWorkbook.Sheets("sheet e")
obj6.Range("C4:C12").Value = obj6.Range("B4:B12").Value
obj6.Range("H4:H8").Value = obj6.Range("G4:G8").Value
obj6.Range("N4:N11").Value = obj6.Range("M4:M11").Value
obj6.Range("S4:S10").Value = obj6.Range("R4:R10").Value
obj6.Range("X4:X18").Value = obj6.Range("W4:W18").Value
obj6.Range("AD4:AD9").Value = obj6.Range("AC4:AC9").Value
obj6.Range("AI4:AI13").Value = obj6.Range("AH4:AH13").Value
obj6.Range("AO4:AO6").Value = obj6.Range("AN4:AN6").Value
obj6.Range("AT4:AT11").Value = obj6.Range("AS4:AS11").Value
obj6.Range("AY4:AY20").Value = obj6.Range("AX4:AX20").Value
obj6.Range("BD4:BD10").Value = obj6.Range("BC4:BC10").Value
obj6.Range("BI4:BI21").Value = obj6.Range("BH4:BH21").Value

Set obj7 = ActiveWorkbook.Sheets("sheet i")
obj7.Range("C4:C12").Value = obj7.Range("B4:B12").Value
obj7.Range("H4:H8").Value = obj7.Range("G4:G8").Value
obj7.Range("N4:N11").Value = obj7.Range("M4:M11").Value
obj7.Range("S4:S10").Value = obj7.Range("R4:R10").Value
obj7.Range("X4:X18").Value = obj7.Range("W4:W18").Value
obj7.Range("AD4:AD9").Value = obj7.Range("AC4:AC9").Value
obj7.Range("AI4:AI13").Value = obj7.Range("AH4:AH13").Value
obj7.Range("AO4:AO6").Value = obj7.Range("AN4:AN6").Value
obj7.Range("AT4:AT11").Value = obj7.Range("AS4:AS11").Value
obj7.Range("AY4:AY20").Value = obj7.Range("AX4:AX20").Value
obj7.Range("BD4:BD10").Value = obj7.Range("BC4:BC10").Value
obj7.Range("BI4:BI21").Value = obj7.Range("BH4:BH21").Value


End Sub









share|improve this question

























  • Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

    – teylyn
    Nov 14 '18 at 6:33











  • Thanks for your reply. I have now posted my code in question. Can you please now help me.

    – user824565
    Nov 14 '18 at 6:43











  • What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

    – teylyn
    Nov 14 '18 at 6:51













  • we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

    – user824565
    Nov 14 '18 at 7:52






  • 1





    Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

    – teylyn
    Nov 14 '18 at 8:35
















0












0








0








I have tables in different sheets of excel and requirement is to copy second last row of table to last row. Can someone pls help me how can we dynamically find table size so that code wont be required to change evrytime when table size changes? There are many tables and we want to automate this task using vba code and macro button.



I have written a code but that is range specific and everytime I need to update the range and process become cumbersome.



Sub history_copy()

Set obj = ActiveWorkbook.Sheets("sheet A")
obj.Range("E12:N12").Value = obj.Range("E11:N11").Value
obj.Range("E34:N34").Value = obj.Range("E33:N33").Value
obj.Range("E46:N46").Value = obj.Range("E45:N45").Value
obj.Range("E57:N57").Value = obj.Range("E56:N56").Value

Set obj1 = ActiveWorkbook.Sheets("sheet b ")
obj1.Range("G21:O21").Value = obj1.Range("G20:O20").Value

Set obj2 = ActiveWorkbook.Sheets("sheet c")
obj2.Range("D4:M4").Value = obj2.Range("D3:M3").Value
obj2.Range("D14:M14").Value = obj2.Range("D13:M13").Value
obj2.Range("D23:M23").Value = obj2.Range("D22:M22").Value
obj2.Range("D33:M33").Value = obj2.Range("D32:M32").Value
obj2.Range("D43:M43").Value = obj2.Range("D42:M42").Value
obj2.Range("D52:M52").Value = obj2.Range("D51:M51").Value
obj2.Range("D61:M61").Value = obj2.Range("D60:M60").Value
obj2.Range("D70:M70").Value = obj2.Range("D69:M69").Value
obj2.Range("D79:M79").Value = obj2.Range("D78:M78").Value
obj2.Range("D88:M88").Value = obj2.Range("D87:M87").Value
obj2.Range("D97:M97").Value = obj2.Range("D96:M96").Value
obj2.Range("D106:M106").Value = obj2.Range("D105:M105").Value
obj2.Range("D114:M114").Value = obj2.Range("D113:M113").Value

Set obj3 = ActiveWorkbook.Sheets("sheet d")
obj3.Range("D4:L4").Value = obj3.Range("D3:L3").Value



Set obj5 = ActiveWorkbook.Sheets("sheet f")
obj5.Range("D4:L4").Value = obj5.Range("D3:L3").Value

Set obj6 = ActiveWorkbook.Sheets("sheet e")
obj6.Range("C4:C12").Value = obj6.Range("B4:B12").Value
obj6.Range("H4:H8").Value = obj6.Range("G4:G8").Value
obj6.Range("N4:N11").Value = obj6.Range("M4:M11").Value
obj6.Range("S4:S10").Value = obj6.Range("R4:R10").Value
obj6.Range("X4:X18").Value = obj6.Range("W4:W18").Value
obj6.Range("AD4:AD9").Value = obj6.Range("AC4:AC9").Value
obj6.Range("AI4:AI13").Value = obj6.Range("AH4:AH13").Value
obj6.Range("AO4:AO6").Value = obj6.Range("AN4:AN6").Value
obj6.Range("AT4:AT11").Value = obj6.Range("AS4:AS11").Value
obj6.Range("AY4:AY20").Value = obj6.Range("AX4:AX20").Value
obj6.Range("BD4:BD10").Value = obj6.Range("BC4:BC10").Value
obj6.Range("BI4:BI21").Value = obj6.Range("BH4:BH21").Value

Set obj7 = ActiveWorkbook.Sheets("sheet i")
obj7.Range("C4:C12").Value = obj7.Range("B4:B12").Value
obj7.Range("H4:H8").Value = obj7.Range("G4:G8").Value
obj7.Range("N4:N11").Value = obj7.Range("M4:M11").Value
obj7.Range("S4:S10").Value = obj7.Range("R4:R10").Value
obj7.Range("X4:X18").Value = obj7.Range("W4:W18").Value
obj7.Range("AD4:AD9").Value = obj7.Range("AC4:AC9").Value
obj7.Range("AI4:AI13").Value = obj7.Range("AH4:AH13").Value
obj7.Range("AO4:AO6").Value = obj7.Range("AN4:AN6").Value
obj7.Range("AT4:AT11").Value = obj7.Range("AS4:AS11").Value
obj7.Range("AY4:AY20").Value = obj7.Range("AX4:AX20").Value
obj7.Range("BD4:BD10").Value = obj7.Range("BC4:BC10").Value
obj7.Range("BI4:BI21").Value = obj7.Range("BH4:BH21").Value


End Sub









share|improve this question
















I have tables in different sheets of excel and requirement is to copy second last row of table to last row. Can someone pls help me how can we dynamically find table size so that code wont be required to change evrytime when table size changes? There are many tables and we want to automate this task using vba code and macro button.



I have written a code but that is range specific and everytime I need to update the range and process become cumbersome.



Sub history_copy()

Set obj = ActiveWorkbook.Sheets("sheet A")
obj.Range("E12:N12").Value = obj.Range("E11:N11").Value
obj.Range("E34:N34").Value = obj.Range("E33:N33").Value
obj.Range("E46:N46").Value = obj.Range("E45:N45").Value
obj.Range("E57:N57").Value = obj.Range("E56:N56").Value

Set obj1 = ActiveWorkbook.Sheets("sheet b ")
obj1.Range("G21:O21").Value = obj1.Range("G20:O20").Value

Set obj2 = ActiveWorkbook.Sheets("sheet c")
obj2.Range("D4:M4").Value = obj2.Range("D3:M3").Value
obj2.Range("D14:M14").Value = obj2.Range("D13:M13").Value
obj2.Range("D23:M23").Value = obj2.Range("D22:M22").Value
obj2.Range("D33:M33").Value = obj2.Range("D32:M32").Value
obj2.Range("D43:M43").Value = obj2.Range("D42:M42").Value
obj2.Range("D52:M52").Value = obj2.Range("D51:M51").Value
obj2.Range("D61:M61").Value = obj2.Range("D60:M60").Value
obj2.Range("D70:M70").Value = obj2.Range("D69:M69").Value
obj2.Range("D79:M79").Value = obj2.Range("D78:M78").Value
obj2.Range("D88:M88").Value = obj2.Range("D87:M87").Value
obj2.Range("D97:M97").Value = obj2.Range("D96:M96").Value
obj2.Range("D106:M106").Value = obj2.Range("D105:M105").Value
obj2.Range("D114:M114").Value = obj2.Range("D113:M113").Value

Set obj3 = ActiveWorkbook.Sheets("sheet d")
obj3.Range("D4:L4").Value = obj3.Range("D3:L3").Value



Set obj5 = ActiveWorkbook.Sheets("sheet f")
obj5.Range("D4:L4").Value = obj5.Range("D3:L3").Value

Set obj6 = ActiveWorkbook.Sheets("sheet e")
obj6.Range("C4:C12").Value = obj6.Range("B4:B12").Value
obj6.Range("H4:H8").Value = obj6.Range("G4:G8").Value
obj6.Range("N4:N11").Value = obj6.Range("M4:M11").Value
obj6.Range("S4:S10").Value = obj6.Range("R4:R10").Value
obj6.Range("X4:X18").Value = obj6.Range("W4:W18").Value
obj6.Range("AD4:AD9").Value = obj6.Range("AC4:AC9").Value
obj6.Range("AI4:AI13").Value = obj6.Range("AH4:AH13").Value
obj6.Range("AO4:AO6").Value = obj6.Range("AN4:AN6").Value
obj6.Range("AT4:AT11").Value = obj6.Range("AS4:AS11").Value
obj6.Range("AY4:AY20").Value = obj6.Range("AX4:AX20").Value
obj6.Range("BD4:BD10").Value = obj6.Range("BC4:BC10").Value
obj6.Range("BI4:BI21").Value = obj6.Range("BH4:BH21").Value

Set obj7 = ActiveWorkbook.Sheets("sheet i")
obj7.Range("C4:C12").Value = obj7.Range("B4:B12").Value
obj7.Range("H4:H8").Value = obj7.Range("G4:G8").Value
obj7.Range("N4:N11").Value = obj7.Range("M4:M11").Value
obj7.Range("S4:S10").Value = obj7.Range("R4:R10").Value
obj7.Range("X4:X18").Value = obj7.Range("W4:W18").Value
obj7.Range("AD4:AD9").Value = obj7.Range("AC4:AC9").Value
obj7.Range("AI4:AI13").Value = obj7.Range("AH4:AH13").Value
obj7.Range("AO4:AO6").Value = obj7.Range("AN4:AN6").Value
obj7.Range("AT4:AT11").Value = obj7.Range("AS4:AS11").Value
obj7.Range("AY4:AY20").Value = obj7.Range("AX4:AX20").Value
obj7.Range("BD4:BD10").Value = obj7.Range("BC4:BC10").Value
obj7.Range("BI4:BI21").Value = obj7.Range("BH4:BH21").Value


End Sub






excel vba excel-vba copy-paste






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 7:50









Pᴇʜ

21.7k42750




21.7k42750










asked Nov 14 '18 at 6:21









user824565user824565

61




61













  • Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

    – teylyn
    Nov 14 '18 at 6:33











  • Thanks for your reply. I have now posted my code in question. Can you please now help me.

    – user824565
    Nov 14 '18 at 6:43











  • What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

    – teylyn
    Nov 14 '18 at 6:51













  • we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

    – user824565
    Nov 14 '18 at 7:52






  • 1





    Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

    – teylyn
    Nov 14 '18 at 8:35





















  • Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

    – teylyn
    Nov 14 '18 at 6:33











  • Thanks for your reply. I have now posted my code in question. Can you please now help me.

    – user824565
    Nov 14 '18 at 6:43











  • What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

    – teylyn
    Nov 14 '18 at 6:51













  • we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

    – user824565
    Nov 14 '18 at 7:52






  • 1





    Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

    – teylyn
    Nov 14 '18 at 8:35



















Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

– teylyn
Nov 14 '18 at 6:33





Please understand that this site is not a free programming service. We can help you if you get stuck with your code, but you have to be able to write code yourself. Post the code you have so far and explain what you need help with. Please edit your question to provide these details. Do not do that in a comment. Post a comment when you have updated your question to alert your followers.

– teylyn
Nov 14 '18 at 6:33













Thanks for your reply. I have now posted my code in question. Can you please now help me.

– user824565
Nov 14 '18 at 6:43





Thanks for your reply. I have now posted my code in question. Can you please now help me.

– user824565
Nov 14 '18 at 6:43













What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

– teylyn
Nov 14 '18 at 6:51







What is your data structure? You have several references to different rows in column E. What is the "second last row of the table"? How do you determine that you need rows 12, 34, 46 and 57 in that sheet? Do you have several tables in the sheet? Are these Excel Table Objects or are these just ranges with some empty rows followed by another range? Your code does not make sense unless we can see the data. Use an ad-free file sharing service to post a REDUCED data sample that illustrates the problem. Ad-free can be DropBox, Box, OneDrive.

– teylyn
Nov 14 '18 at 6:51















we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

– user824565
Nov 14 '18 at 7:52





we have tables in different sheets , we are copying todays value for that table to compare with tomorrows data. last row will have yesterday data and second last row will have todays. this table we have in different sheets and total we are taking in consideration like E2:H2. The range of table is not fixed for each table.

– user824565
Nov 14 '18 at 7:52




1




1





Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

– teylyn
Nov 14 '18 at 8:35







Did you read my last comment about needing to know your data structure? If you don't provide a sample file with your data structure, nobody will be able to help you with your code. When will it be row 3? When will it be row 77? What are the markers to define the logic? If the range is not fixed for each table -- pardon me, but how on earth is Excel going to know what to copy? YOU need to define the logic for that in words, relating to your sample data file that you post in an ad-free file sharing service. I think I'm done here.

– teylyn
Nov 14 '18 at 8:35














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294214%2fautomate-copy-paste-excel-ranges-dynamically-from-different-sheets%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294214%2fautomate-copy-paste-excel-ranges-dynamically-from-different-sheets%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python