![]() |
Automating skipping rows between selected cells. Please Help
Fellow Forum Members,
I would appreciate it a lot if someone can help me develop a macro that will let me selectively copy cells and allow me to control the quantity of rows I need skipped between each copied cell. Currently I press the CONTROL button and manually select 50 cells in "Column A" and manually skip 3 rows between each cell I select to copy. The result is 50 cells selected with three rows in between each selected cell. This is tedious work and I need a macro that would ask me three questions before I run it: Question One: What is the first cell you want to copy? My answer is : "A1" Question Two: Total number of cells you want to copy following Cell "A1"? My answer is : X (Could be 25, 30, 40 could be any number) Question Three: How many rows do you want to skip between each of the copied cells starting with cell "A1" ? My answer is : X (could be 3, 4, 5, 6, 7, could be any number) IS such a macro possible? I need to set this up because I am spending too much time doing this custom type of copying over and over again. I need to tell Excel how many rows to skip between each copied cell. If any one can help me out in developing such a Macro I would be very grateful. Thank you very much. |
Automating skipping rows between selected cells. Please Help
Here it is
'for start enter the row number i.e. 1 and not A1 'if rows to skip is 2 then it will copy row 1,4,7,... 'source sheet1, destination sheet2 Sub copyRows() Dim startRow, noOfRows, totalRows As Long startRow = InputBox("Enter the row to start") noOfRows = InputBox("Enter the no of rows to skip") + 1 totalRows = InputBox("Enter toral no of rows to copy") Application.ScreenUpdating = False For i = 1 To totalRows Worksheets("Sheet1").Select Worksheets("Sheet1").Cells(startRow + (i - 1) * noOfRows, 1).EntireRow.Copy Worksheets("Sheet2").Select Worksheets("Sheet2").Cells(i, 1).PasteSpecial Next Application.ScreenUpdating = True End Sub "binar" wrote: Fellow Forum Members, I would appreciate it a lot if someone can help me develop a macro that will let me selectively copy cells and allow me to control the quantity of rows I need skipped between each copied cell. Currently I press the CONTROL button and manually select 50 cells in "Column A" and manually skip 3 rows between each cell I select to copy. The result is 50 cells selected with three rows in between each selected cell. This is tedious work and I need a macro that would ask me three questions before I run it: Question One: What is the first cell you want to copy? My answer is : "A1" Question Two: Total number of cells you want to copy following Cell "A1"? My answer is : X (Could be 25, 30, 40 could be any number) Question Three: How many rows do you want to skip between each of the copied cells starting with cell "A1" ? My answer is : X (could be 3, 4, 5, 6, 7, could be any number) IS such a macro possible? I need to set this up because I am spending too much time doing this custom type of copying over and over again. I need to tell Excel how many rows to skip between each copied cell. If any one can help me out in developing such a Macro I would be very grateful. Thank you very much. |
Automating skipping rows between selected cells. Please Help
Sheeloo,
Thanks a lot for this script. You are a genuis! This little script of yours works exactly as I envisioned it. It is awesome. I was going to buy the app in the link below and play around with it to see if it could do what I wanted to do in Excel. http://www.tethyssolutions.com/product.htm But since your app is perfect I think I am no longer going to buy it. Again, thanks a lot. You are a talented VBA programmer. P.S. In your last popup window the word "total" is misspelled. However, it was easy enough for me to fix. "Sheeloo" wrote: Here it is 'for start enter the row number i.e. 1 and not A1 'if rows to skip is 2 then it will copy row 1,4,7,... 'source sheet1, destination sheet2 Sub copyRows() Dim startRow, noOfRows, totalRows As Long startRow = InputBox("Enter the row to start") noOfRows = InputBox("Enter the no of rows to skip") + 1 totalRows = InputBox("Enter toral no of rows to copy") Application.ScreenUpdating = False For i = 1 To totalRows Worksheets("Sheet1").Select Worksheets("Sheet1").Cells(startRow + (i - 1) * noOfRows, 1).EntireRow.Copy Worksheets("Sheet2").Select Worksheets("Sheet2").Cells(i, 1).PasteSpecial Next Application.ScreenUpdating = True End Sub "binar" wrote: Fellow Forum Members, I would appreciate it a lot if someone can help me develop a macro that will let me selectively copy cells and allow me to control the quantity of rows I need skipped between each copied cell. Currently I press the CONTROL button and manually select 50 cells in "Column A" and manually skip 3 rows between each cell I select to copy. The result is 50 cells selected with three rows in between each selected cell. This is tedious work and I need a macro that would ask me three questions before I run it: Question One: What is the first cell you want to copy? My answer is : "A1" Question Two: Total number of cells you want to copy following Cell "A1"? My answer is : X (Could be 25, 30, 40 could be any number) Question Three: How many rows do you want to skip between each of the copied cells starting with cell "A1" ? My answer is : X (could be 3, 4, 5, 6, 7, could be any number) IS such a macro possible? I need to set this up because I am spending too much time doing this custom type of copying over and over again. I need to tell Excel how many rows to skip between each copied cell. If any one can help me out in developing such a Macro I would be very grateful. Thank you very much. |
Automating skipping rows between selected cells. Please Help
Sheeloo,
Thanks a lot for this script. You are a genuis! This little script of yours works exactly as I envisioned it. It is awesome. I was going to buy the app in the link below and play around with it to see if it could do what I wanted to do in Excel. http://www.tethyssolutions.com/product.htm But since your app is perfect I think I am no longer going to buy it. Again, thanks a lot. You are a talented VBA programmer. P.S. In your last popup window the word "total" is misspelled. However, it was easy enough for me to fix. "Sheeloo" wrote: Here it is 'for start enter the row number i.e. 1 and not A1 'if rows to skip is 2 then it will copy row 1,4,7,... 'source sheet1, destination sheet2 Sub copyRows() Dim startRow, noOfRows, totalRows As Long startRow = InputBox("Enter the row to start") noOfRows = InputBox("Enter the no of rows to skip") + 1 totalRows = InputBox("Enter toral no of rows to copy") Application.ScreenUpdating = False For i = 1 To totalRows Worksheets("Sheet1").Select Worksheets("Sheet1").Cells(startRow + (i - 1) * noOfRows, 1).EntireRow.Copy Worksheets("Sheet2").Select Worksheets("Sheet2").Cells(i, 1).PasteSpecial Next Application.ScreenUpdating = True End Sub "binar" wrote: Fellow Forum Members, I would appreciate it a lot if someone can help me develop a macro that will let me selectively copy cells and allow me to control the quantity of rows I need skipped between each copied cell. Currently I press the CONTROL button and manually select 50 cells in "Column A" and manually skip 3 rows between each cell I select to copy. The result is 50 cells selected with three rows in between each selected cell. This is tedious work and I need a macro that would ask me three questions before I run it: Question One: What is the first cell you want to copy? My answer is : "A1" Question Two: Total number of cells you want to copy following Cell "A1"? My answer is : X (Could be 25, 30, 40 could be any number) Question Three: How many rows do you want to skip between each of the copied cells starting with cell "A1" ? My answer is : X (could be 3, 4, 5, 6, 7, could be any number) IS such a macro possible? I need to set this up because I am spending too much time doing this custom type of copying over and over again. I need to tell Excel how many rows to skip between each copied cell. If any one can help me out in developing such a Macro I would be very grateful. Thank you very much. |
All times are GMT +1. The time now is 09:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com