Created
September 19, 2022 08:02
-
-
Save YeeBePrime/4da8288a8fb2b7d19943a3be8d3487f9 to your computer and use it in GitHub Desktop.
Remove blank cells in array and shift cells in that row to the left using Excel lambda function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| removeBlankShiftLeft | |
| Description | |
| Remove blank cells in array and shift cells in that row to the left. | |
| Syntax | |
| removeBlankShiftLeft (datarange, [lastresult], [lastrow]) | |
| The removeBlankShiftLeft function syntax has the following arguments: | |
| datarange Required. can be 2D array | |
| lastresult Optional. For recursive purpose only. | |
| lastrow Optional. For recursive purpose only. | |
| Example | |
| A1:C3 A B C | |
| D E | |
| F G H | |
| =removeBlankShiftLeft(A1:C3) | |
| Return | |
| A B C | |
| D E | |
| F G H | |
| */ | |
| removeBlankShiftLeft=LAMBDA(datarange, [lastresult], [lastrow], | |
| LET( | |
| rng, datarange, | |
| _lresult, IF( | |
| ISOMITTED( | |
| lastresult | |
| ), | |
| "", | |
| lastresult | |
| ), | |
| _lrow, lastrow, | |
| _nrow, IF( | |
| _lrow > 0, | |
| _lrow + 1, | |
| 1 | |
| ), | |
| _rngRow, CHOOSEROWS( | |
| rng, | |
| _nrow | |
| ), | |
| result, IFERROR( | |
| VSTACK( | |
| _lresult, | |
| TRIM( | |
| FILTER( | |
| _rngRow, | |
| _rngRow <> | |
| "" | |
| ) | |
| ) | |
| ), | |
| "" | |
| ), | |
| IF( | |
| _nrow + 1 <= | |
| ROWS(rng), | |
| removeBlankShiftLeft( | |
| rng, | |
| result, | |
| _nrow | |
| ), | |
| DROP(result, 1) | |
| ) | |
| ) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment