Jeffrey Mahoney
Well-known Member
- Joined
- May 31, 2015
- Messages
- 3,142
- Office Version
- 365
- Platform
- Windows
I'm using =LAMBDA(Cel,SUM(GET.CELL(16,Cel))) to return the column width with decimals because =Cell("width",A1) only returns the integer value of the cell width. The named range is called CellWidth
Then I wanted to get the total column widths from a range of cells using this:
=LAMBDA(Rng,[X],[Cnt],[Wid],IF(X=0,ColsWidth(Rng,1,COLUMNS(Rng),0),IF(X<Cnt,ColsWidth(Rng,X+1,Cnt,Wid+CellWidth(INDEX(Rng,1,X))),Wid+CellWidth(INDEX(Rng,1,X)))))
It works fine and I call that named range ColsWidth
Then I thought that I could just put the CellWidth formula right into the ColsWidth Lambda formula and write it like this:
=LAMBDA(Rng,[X],[Cnt],[Wid],IF(X=0,ColsWidth(Rng,1,COLUMNS(Rng),0),IF(X<Cnt,ColsWidth(Rng,X+1,Cnt,Wid+Get.Cell(16,INDEX(Rng,1,X))),Wid+Get.Cell(16,INDEX(Rng,1,X)))))
It gives me an error. Am I to assume that the Get.Cell function doesn't know how to work with variables in the Lambda function?
I wanted to post my Lambda function on this site as a stand alone function, but it may turn out that I'll have to provide instructions for the simple CellWidth Lambda also.
Then I wanted to get the total column widths from a range of cells using this:
=LAMBDA(Rng,[X],[Cnt],[Wid],IF(X=0,ColsWidth(Rng,1,COLUMNS(Rng),0),IF(X<Cnt,ColsWidth(Rng,X+1,Cnt,Wid+CellWidth(INDEX(Rng,1,X))),Wid+CellWidth(INDEX(Rng,1,X)))))
It works fine and I call that named range ColsWidth
Then I thought that I could just put the CellWidth formula right into the ColsWidth Lambda formula and write it like this:
=LAMBDA(Rng,[X],[Cnt],[Wid],IF(X=0,ColsWidth(Rng,1,COLUMNS(Rng),0),IF(X<Cnt,ColsWidth(Rng,X+1,Cnt,Wid+Get.Cell(16,INDEX(Rng,1,X))),Wid+Get.Cell(16,INDEX(Rng,1,X)))))
It gives me an error. Am I to assume that the Get.Cell function doesn't know how to work with variables in the Lambda function?
I wanted to post my Lambda function on this site as a stand alone function, but it may turn out that I'll have to provide instructions for the simple CellWidth Lambda also.