Forked from YeeBePrime/excel-lambda-removeBlankShiftLeft.txt
Created
June 15, 2023 14:58
-
-
Save fstfwd/110d408f84adeff8c0d90dddedf9aea5 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