vba commanbutton in sheet

各位高手們

在工作表中使用陣列儲存commandbotton名稱 但卻無法使用隱藏功能, 請各位大大幫幫忙壓

我的寫法如下:

dim data(2),com(4)

data(1)=1

data(2)=2

Sheet1.CB_50.Caption =1

Sheet1.CB_50.Caption =2

com(1) = Sheet1.CB_50.Caption

com(2) = Sheet1.CB_50.Visible

com(3) = Sheet1.CB_51.Caption

com(4) = Sheet1.CB_51.Visible

for i = 1 to 2

for j = 1 to 4 step 2

if data(i)=com(j) then

com(j+1)=false

end if

next

next

請各位高手高手幫幫忙壓 拜託拜託

1 Answer

Rating
  • 阿戊
    Lv 7
    7 years ago
    Best Answer

    caption只是顯示的文字,有可能重複,你要記錄的話 可以改用名稱,名稱才有獨一性!

    而 由名稱去控制物件 要這樣:

    data(1)="CB_51"

    Sheet1.Shapes(data(1)).Visible = False

Still have questions? Get your answers by asking now.