隐藏/取消隐藏基于动态更改单元格值的命令按钮

时间:2016-11-30 21:14:19

标签: excel vba excel-vba

我想创建一些VBA代码,根据单元格的值隐藏命令按钮。

如果是" S17" ="(全部)"然后应该隐藏命令按钮,否则它可以保持可见。

正如我所说,单元格S17中的值会动态变化,因此只要用户进行更改,代码就需要更新。

到目前为止,这是我的代码:

Private Sub Worksheet_Change(ByVal Target As Range)
 If Sheet3.Range("S17").Value = "(All)" Then
 CommandButton6.Visible = False
Else
 CommandButton6.Visible = True
End If
End Sub

目前,这并没有做任何事情。如果单元格S17 ="(全部)"命令按钮仍然可见。

1 个答案:

答案 0 :(得分:1)

这是你的代码 -

package demo;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.*;

public class PDFGenerateDemo {

    public static void main(String[] args) 
        throws Exception {

        Document document = new Document();
         PdfWriter.getInstance(document,
          new FileOutputStream("/Users/PandaFunk/Desktop/images/sample.pdf"));

      document.open();
      Paragraph paragraph = new Paragraph();

      paragraph.add("Hello World\n");
      paragraph.add("PDF sample generation demo\n");
      paragraph.add("programmed by Mon Zalameda\n");
      paragraph.add("DLS-CSB is a wonderful school. "
            + "I will miss you and hope "
            + "to see you again.\n\n");

      //adding Image
      Image csbImage = 
            Image.getInstance("/Users/PandaFunk/Desktop/images/DLS-CSB_Seal.png");

      document.add(paragraph);
      document.add(csbImage);
      document.close();
    }
}