查找行中倒数第二个值的公式-Excel

时间:2018-08-10 12:55:38

标签: excel-formula

我有公式来查找行中的最后一个值-= LOOKUP(1,1 /(3:3> 0),3:3)(取决于行)

,但似乎无法让它返回行中倒数第二个值/单元格。

请帮助!

3 个答案:

答案 0 :(得分:0)

尝试

=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A:XFC)/(A3:XFC3>0), 2))

答案 1 :(得分:0)

棒极了..我将公式编辑为:

import { Component,AfterContentInit,AfterViewInit,AfterViewChecked } from '@angular/core';
import { Location,PopStateEvent} from '@angular/common';
import * as myGlobals from './global_variable';
import { headerComponent } from './components/header/header.component';
import { footerComponent }   from './components/footer/footer.component';
import { sidebarComponent }   from './components/sidebar/sidebar.component';
import { mainPageComponent }   from './components/main/mainpage.component';
import { Routes, RouterModule ,ActivatedRoute,Router,NavigationEnd,NavigationStart , ExtraOptions} from '@angular/router';
import {AuthService} from './services/auth.service';


@Component({
  selector: 'my-app',
  templateUrl: './app.component.html'
})
export class AppComponent { 
public hideHeader:any = false;
public showHeader:any;
public showSidebarTrial:any = false;
public param_id:any;
headerTrialEmitter(e:any)
{
    this.showSidebarTrial = e.value;
}
    onActivate(e){
       //alert(1.5);
    }
 
    onDeactivate(e)
    {
     // alert(1);
      if(myGlobals.getCookie(window.location.pathname) == ''){
            document.body.scrollTop = 0;
           
        }else{
           setTimeout(()=>{
         //    alert(2);
            document.documentElement.scrollTop = Number(myGlobals.getCookie(window.location.pathname));
             if(document.documentElement.scrollTop == 0){
               document.body.scrollTop = Number(myGlobals.getCookie(window.location.pathname));

             }
           },2500);
            
        }
       
    }

constructor(private route:ActivatedRoute,private cons:RouterModule,public Location:Location,private router: Router,private AuthService:AuthService){


 router.events.subscribe((val) => {
          var patt = new RegExp("/reset-password/");
          var found_rp = false;
          if(patt.test(window.location.pathname))
          {
             found_rp = true;
          }

        if(val.url == '/login' || val.url == '/please-help' || val.url == '/reset-password' || found_rp){
        	this.hideHeader = false;

        } else{

        	this.hideHeader = true;
        }
    });
 
  this.router.events
        .filter(e => e instanceof NavigationStart)
        .pairwise().subscribe((e:any) => {
            console.log(e,'pairwise');
        //    alert(window.location.pathname);
          //  alert(document.body.scrollTop);
            if(e[0].url == '/login'){

            }else if(e[0].url == e[1].url){

            }else{

              var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
              myGlobals.setCookie(e[0].url,scrollTop);
              var cookies = document.cookie.split(";");
              if(cookies.length > 2){
                for(var i = 0;i < cookies.length;i++){
                  myGlobals.deleteCookie('')
                }
              }
            }
        });

if(window.location.pathname == "/login" || window.location.pathname == "/please-help"){

    this.hideHeader = false;
//    console.log("hideHeader1 true");

}else{

this.hideHeader = true;

}
}

}

BL3是我当前的最后一个数据值结束的位置。拖动后,公式会自动更新列和行的值。

非常感谢!

答案 2 :(得分:0)

对于第3行,数组公式

=INDEX(3:3,IF(COUNTA(3:3)=0,"",MAX((3:3<>"")*(COLUMN(3:3))))-1)

将在该行产生倒数第二个值:

enter image description here

数组公式必须使用 Ctrl + Shift + Enter 输入,而不仅仅是 Enter 键。如果正确完成此操作,则公式将显示在公式栏中,并带有大括号。

如果您确定第3行不会为空,请改用以下数组公式:

=INDEX(3:3,MAX((3:3<>"")*(COLUMN(3:3)))-1)

为避免使用数组公式,请考虑:

=INDEX(3:3,SUMPRODUCT(MAX((COLUMN(3:3))*(3:3<>"")))-1)