mike guest98
New member
- Joined
- Jun 6, 2018
- Messages
- 28
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- 2010
I would need assistance with developing a new macro. The macro does 2 things: search in a range for numbers 1 to 10 and divide certain numbers by 10, that’s it.
I have 3 examples at the end and have uploaded my sample Excel workbook showing the expected result.
Thank-you in advance for your assistance.
Notes for below:
- Need 2 decimal places on the left and 2 decimal places on the right in every cell.
- I’m using Excel 2010, Sheet 2.
- Please do not hard code I may need to make changes in the future.
1st to do - is to find each possible number in the range and how it must be written. There will always be a positive result with a minimum of 1 and a maximum of 10 (could be expanded in the future) numbers found.
Found number 1, 2, 3, 4 with a positive result:
- Write specific cell location:
Number 1 from cell range, B17:B26, F17:F26, J17:J26 write to cell B7.
Number 2 from cell range, B17:B26, F17:F26, J17:J26 write to cell D7.
Number 3 from cell range, B17:B26, F17:F26, J17:J26 write to cell F7.
Number 4 from cell range, B17:B26, F17:F26, J17:J26 write to cell H7.
Found numbers 5, 6, 7, 8, 9, 10 with a positive result:
Number 5 from cell range, B17:B26, F17:F26, J17:J26 write to cell J7.
Number 6 from cell range, B17:B26, F17:F26, J17:J26 write to cell B14.
Number 7 from cell range, B17:B26, F17:F26, J17:J26 write to cell D14.
Number 8 from cell range, B17:B26, F17:F26, J17:J26 write to cell F14.
Number 9 from cell range, B17:B26, F17:F26, J17:J26 write to cell H14.
Number 10 from cell range, B17:B26, F17:F26, J17:J26 write to cell J14.
2nd to do - Divide the number (located in columns E/I/M, 3 cells to the right of the found number) by 10 up to the number 12.00. After 12.00 the remainder would be written to the listed cell. Add to any existing numbers in any of the cells.
3 Examples with expected results – see sample Excel sheet
The above code is run and the following would occur:
1st Found number – Number 4
- Write B20 (number 4 location) to cell H7.
- Divide 10.00 located in cell E20 by 10 cells C7,E7,G7,I7,K7,C14,E14,G14,I14,K14. Add to any existing numbers in the cell.
2nd Found number - Number 9
- Write F18 (number 9 cell location) to cell H14.
- Write cell contents I18 (10.00) to cell I14, Add to any existing numbers in the cell.
3rd Found Number - Number 1
- Write J26 (number 1 cell location) to cell B7.
- Divide 12.00 by 10 cells C7,E7,G7,I7,K7,C14,E14,G14,I14,K14. The remaining 8.00 would be written to cell C7. Add to any existing numbers in the cell.
Thank-you in advance for any help you can provide.
I have 3 examples at the end and have uploaded my sample Excel workbook showing the expected result.
Thank-you in advance for your assistance.
Notes for below:
- Need 2 decimal places on the left and 2 decimal places on the right in every cell.
- I’m using Excel 2010, Sheet 2.
- Please do not hard code I may need to make changes in the future.
1st to do - is to find each possible number in the range and how it must be written. There will always be a positive result with a minimum of 1 and a maximum of 10 (could be expanded in the future) numbers found.
Found number 1, 2, 3, 4 with a positive result:
- Write specific cell location:
Number 1 from cell range, B17:B26, F17:F26, J17:J26 write to cell B7.
Number 2 from cell range, B17:B26, F17:F26, J17:J26 write to cell D7.
Number 3 from cell range, B17:B26, F17:F26, J17:J26 write to cell F7.
Number 4 from cell range, B17:B26, F17:F26, J17:J26 write to cell H7.
Found numbers 5, 6, 7, 8, 9, 10 with a positive result:
Number 5 from cell range, B17:B26, F17:F26, J17:J26 write to cell J7.
Number 6 from cell range, B17:B26, F17:F26, J17:J26 write to cell B14.
Number 7 from cell range, B17:B26, F17:F26, J17:J26 write to cell D14.
Number 8 from cell range, B17:B26, F17:F26, J17:J26 write to cell F14.
Number 9 from cell range, B17:B26, F17:F26, J17:J26 write to cell H14.
Number 10 from cell range, B17:B26, F17:F26, J17:J26 write to cell J14.
2nd to do - Divide the number (located in columns E/I/M, 3 cells to the right of the found number) by 10 up to the number 12.00. After 12.00 the remainder would be written to the listed cell. Add to any existing numbers in any of the cells.
3 Examples with expected results – see sample Excel sheet
The above code is run and the following would occur:
1st Found number – Number 4
- Write B20 (number 4 location) to cell H7.
- Divide 10.00 located in cell E20 by 10 cells C7,E7,G7,I7,K7,C14,E14,G14,I14,K14. Add to any existing numbers in the cell.
2nd Found number - Number 9
- Write F18 (number 9 cell location) to cell H14.
- Write cell contents I18 (10.00) to cell I14, Add to any existing numbers in the cell.
3rd Found Number - Number 1
- Write J26 (number 1 cell location) to cell B7.
- Divide 12.00 by 10 cells C7,E7,G7,I7,K7,C14,E14,G14,I14,K14. The remaining 8.00 would be written to cell C7. Add to any existing numbers in the cell.
Thank-you in advance for any help you can provide.