如何在VBA中使用If-Then有条件跨工作簿?

时间:2019-06-26 03:15:13

标签: excel vba if-statement sum

我想在两个工作簿中使用if-then语句。

我已将x定义为Long,但是x似乎不保存B列中所有单元格的和值。

但是代码看起来正确,有什么想法吗?


import { Component, AfterViewInit, ViewChild, ElementRef } from "@angular/core";

declare let videojs: any;

@Component({
  selector: "app-home",
  templateUrl: "home.page.html",
  styleUrls: ["home.page.scss"]
})
export class HomePage implements AfterViewInit {
  constructor() {}

  vidObj: any;

  @ViewChild("myvid") vid: ElementRef;

  // videoタグのオプション
  ngAfterViewInit() {
    const options = {
      controls: true,
      autoplay: false,
      preload: "auto",
      techOrder: ["html5"],
      controlBar: {
        currentTimeDisplay: true,
        volumePanel: false,
        muteToggle: false,
        fullscreenToggle: false
      }
    };

    this.vidObj = new videojs(
      this.vid.nativeElement,
      options,
      function onPlayerReady() {
        videojs.log("Your player is ready!");
      }
    );
  }

  ChangeFullScreen(event) {
    if (this.vid.nativeElement.requestFullscreen) {
      this.vid.nativeElement.requestFullscreen();
    }
  }

  onClick(error: any) {
    // もしフルスクリーンにできれば(表示が可能か否)
    if (this.vid.nativeElement.requestFullscreen) {
      this.vid.nativeElement.requestFullscreen();

      console.log("fullscreen success");
    } else {
      console.log("fullscreen con not success");
      console.log(error);
    }
  }
}


1 个答案:

答案 0 :(得分:0)

例如:

Sub MyCode()
    Dim myRange As Range
    Set myRange = Workbooks("Book2").Sheets("Sheet1").Columns(2)

    If Workbooks("Book1").Sheets("Sheet1").Range("A1").Value = WorksheetFunction.Sum(myRange) Then
        MsgBox "Values equal"
    Else
        MsgBox "Please review values"
    End If
End Sub