NANCY SKYES
New Member
- Joined
- Aug 12, 2019
- Messages
- 13
Hi
I have data located in 1 row across 4 columns in many different ranges, an example is:
cell C38 cell D38 cell E38 cell F38
10-18 1.00 2.00 3.00
This is only my second post and I think this is possible so here goes. I was looking for help to develop a macro that:
1) [FONT=Liberation Serif, Times New Roman, serif]Searches about 20 different ranges, C[/FONT]<code class="western">[FONT=Liberation Serif, Times New Roman, serif]20:C50,P20:P50,Z20:Z50,AE20:AE50 [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]with the same start line of 20 and the same end line of 50[/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif] (not all listed here, need macro to be hard coded to add/delete as necessary also, [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]I[/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif] have data above and below [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]all the [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]search ranges)[/FONT]</code>[FONT=Liberation Serif, Times New Roman, serif] [/FONT][FONT=Liberation Serif, Times New Roman, serif]for sets of numbers (such as 10-10, 20-1 etc). The numbers are always separated by a dash. Most cells in the ranges will be blank but there will always be data (a set of numbers) in at least 2 [/FONT][FONT=Liberation Serif, Times New Roman, serif]of the [/FONT][FONT=Liberation Serif, Times New Roman, serif]ranges. Other ranges may [/FONT][FONT=Liberation Serif, Times New Roman, serif]or may not[/FONT][FONT=Liberation Serif, Times New Roman, serif] be [/FONT][FONT=Liberation Serif, Times New Roman, serif]blank[/FONT][FONT=Liberation Serif, Times New Roman, serif]. [/FONT]
2) When the code finds a set of numbers I need it to move that set of numbers down to the cell directly below it. The issue here is if there is a set of numbers already in that cell that set of numbers must be moved first down by one cell. The issue is no cell should be overwritten by new data from the above cell. Also, I need the code to delete the contents in the three cells to the right of the found set of numbers (above that would be delete cells D38/E38/F38). The data in the 3 cells deleted is written by another macro I use.
3) The next request is that when the set of numbers gets moved down that only the 2nd set of numbers would be increased by one (10-1 would become 10-2). Please see my sample data below.
4) I would also need the code to search for sets of numbers that have a 20 in the second number and move that set of numbers by two cells down and increase the last number by one. There is an empty row below all the sets of numbers that reach 20. An example would be 2-20 would become 2-21 two cells down from where it was found.
Additional information
- The sheet name is Sheet 1 and their is only one sheet in the workbook.
- Using Excel 2007.
- The search range cells are formatted as text.
- The write cells are formatted as general.
Sample data:
1) The code searches [FONT=Liberation Serif, Times New Roman, serif]C[/FONT]<code class="western">[FONT=Liberation Serif, Times New Roman, serif]20:C50,P20:P50,Z20:Z50,AE20:AE50[/FONT]</code>. The first found set of numbers is 10-18 in cell C38. The code would check the cell contents for any existing data first and then move the data in cell C38 to cell C39 and increase the last number by 1. The code would also clear contents in cells D38/E38/F38. The expected result is 10-39 in cell C39.
2) The second found set of numbers would be 9-20 in cell P40. The code would write 9-21 in cell P42, moving two cells down because of the last number being 20. The code would also clear contents in cells Q38/R38/S38. The expected result is 9-42 in cell P42.
I hope I’m clear but if you have any questions please ask so I can clarify any issue(s).
Thanks so much for all your help.
<style type="text/css">p { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }p.western { font-family: "Times New Roman", serif; font-size: 12pt; }p.cjk { font-family: "SimSun"; font-size: 12pt; }p.ctl { font-family: "Mangal"; font-size: 12pt; }code.western { font-family: "Liberation Mono", "Courier New", monospace; }code.cjk { font-family: "WenQuanYi Micro Hei Mono", monospace; }code.ctl { font-family: "Liberation Mono", "Courier New", monospace; }a:link { }</style>
I have data located in 1 row across 4 columns in many different ranges, an example is:
cell C38 cell D38 cell E38 cell F38
10-18 1.00 2.00 3.00
This is only my second post and I think this is possible so here goes. I was looking for help to develop a macro that:
1) [FONT=Liberation Serif, Times New Roman, serif]Searches about 20 different ranges, C[/FONT]<code class="western">[FONT=Liberation Serif, Times New Roman, serif]20:C50,P20:P50,Z20:Z50,AE20:AE50 [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]with the same start line of 20 and the same end line of 50[/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif] (not all listed here, need macro to be hard coded to add/delete as necessary also, [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]I[/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif] have data above and below [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]all the [/FONT]</code><code class="western">[FONT=Liberation Serif, Times New Roman, serif]search ranges)[/FONT]</code>[FONT=Liberation Serif, Times New Roman, serif] [/FONT][FONT=Liberation Serif, Times New Roman, serif]for sets of numbers (such as 10-10, 20-1 etc). The numbers are always separated by a dash. Most cells in the ranges will be blank but there will always be data (a set of numbers) in at least 2 [/FONT][FONT=Liberation Serif, Times New Roman, serif]of the [/FONT][FONT=Liberation Serif, Times New Roman, serif]ranges. Other ranges may [/FONT][FONT=Liberation Serif, Times New Roman, serif]or may not[/FONT][FONT=Liberation Serif, Times New Roman, serif] be [/FONT][FONT=Liberation Serif, Times New Roman, serif]blank[/FONT][FONT=Liberation Serif, Times New Roman, serif]. [/FONT]
2) When the code finds a set of numbers I need it to move that set of numbers down to the cell directly below it. The issue here is if there is a set of numbers already in that cell that set of numbers must be moved first down by one cell. The issue is no cell should be overwritten by new data from the above cell. Also, I need the code to delete the contents in the three cells to the right of the found set of numbers (above that would be delete cells D38/E38/F38). The data in the 3 cells deleted is written by another macro I use.
3) The next request is that when the set of numbers gets moved down that only the 2nd set of numbers would be increased by one (10-1 would become 10-2). Please see my sample data below.
4) I would also need the code to search for sets of numbers that have a 20 in the second number and move that set of numbers by two cells down and increase the last number by one. There is an empty row below all the sets of numbers that reach 20. An example would be 2-20 would become 2-21 two cells down from where it was found.
Additional information
- The sheet name is Sheet 1 and their is only one sheet in the workbook.
- Using Excel 2007.
- The search range cells are formatted as text.
- The write cells are formatted as general.
Sample data:
1) The code searches [FONT=Liberation Serif, Times New Roman, serif]C[/FONT]<code class="western">[FONT=Liberation Serif, Times New Roman, serif]20:C50,P20:P50,Z20:Z50,AE20:AE50[/FONT]</code>. The first found set of numbers is 10-18 in cell C38. The code would check the cell contents for any existing data first and then move the data in cell C38 to cell C39 and increase the last number by 1. The code would also clear contents in cells D38/E38/F38. The expected result is 10-39 in cell C39.
2) The second found set of numbers would be 9-20 in cell P40. The code would write 9-21 in cell P42, moving two cells down because of the last number being 20. The code would also clear contents in cells Q38/R38/S38. The expected result is 9-42 in cell P42.
I hope I’m clear but if you have any questions please ask so I can clarify any issue(s).
Thanks so much for all your help.
<style type="text/css">p { margin-bottom: 0.21cm; direction: ltr; color: rgb(0, 0, 0); }p.western { font-family: "Times New Roman", serif; font-size: 12pt; }p.cjk { font-family: "SimSun"; font-size: 12pt; }p.ctl { font-family: "Mangal"; font-size: 12pt; }code.western { font-family: "Liberation Mono", "Courier New", monospace; }code.cjk { font-family: "WenQuanYi Micro Hei Mono", monospace; }code.ctl { font-family: "Liberation Mono", "Courier New", monospace; }a:link { }</style>