Phil Payne
Board Regular
- Joined
- May 17, 2013
- Messages
- 131
- Office Version
- 365
- Platform
- Windows
Hello all,
I have a worksheet which is an output from a database. (Example below)
I need to populate the empty cells in columns B and C with the data in the cells immediately above and the code I have (also below) works well if run in isolation.
However I have now combined this code with other code into one macro and I receive an error (Debug) message "No cells were found" on line 3 'selection.specialcells'.
Is there a way to avoid this? I cannot work out how to specify the last row of the range, as the number of rows will change (increase) over time.
Can anyone assist please?
Thanks in anticipation.
<tbody>
</tbody>
I have a worksheet which is an output from a database. (Example below)
I need to populate the empty cells in columns B and C with the data in the cells immediately above and the code I have (also below) works well if run in isolation.
However I have now combined this code with other code into one macro and I receive an error (Debug) message "No cells were found" on line 3 'selection.specialcells'.
Is there a way to avoid this? I cannot work out how to specify the last row of the range, as the number of rows will change (increase) over time.
Can anyone assist please?
Thanks in anticipation.
Code:
'MsgBox "Fill empty cells in columns B C with entry above"
Range("a3:d3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
A | B | C | D | |
1 | 1 | dfgh | dfhdfh | dfhh |
2 | 2 | WBS Element | Establishment | Cost Element |
3 | 3 | WBS 001 | Abercorn | 504307 |
4 | 4 | 504401 | ||
5 | 5 | 504402 | ||
6 | 6 | Result | ||
7 | 7 | WBS 003 | Anderson | 504307 |
8 | 8 | 504402 | ||
9 | 9 | Result | ||
10 | 10 | WBS 099 | Achcraig | 504126 |
11 | 11 | 504307 | ||
12 | 12 | Result | ||
13 | 13 | WBS 102 | Balornock | 504122 |
14 | 14 | 504129 | ||
15 | 15 | 504307 | ||
16 | 16 | 504402 | ||
17 | 17 | Result |
<tbody>
</tbody>