如果工作表不可见,VBA会给出错误

时间:2017-09-25 18:50:46

标签: visible worksheet

在我的代码中,有一些是指其他工作表,但我不知道为什么,如果这些工作表不可见,宏会给出错误:"工作表类的可见方法失败"。

你们能帮助我吗?

代码就像这样开始,我只是用' Worksheets("Ders_TEMP").Visible

Sub Ders_Rapor()

Application.ScreenUpdating = False

LastRowXLC = Worksheets("Egitim Bilgileri").Cells(Rows.Count, 1).End(xlUp).Row

Ders_Adi_Sec.ComboBox1.List = Worksheets("Egitim Bilgileri").Range("C2:C" & LastRowXLC & "").Value
Ders_Adi_Sec.Show

Worksheet_Bilgiler = "Egitim Bilgileri"
If Ders_Adi_Sec.ComboBox1.Value = "" Then MsgBox "Lütfen Ders Seçiniz"
If Ders_Adi_Sec.ComboBox1.Value = "" Then GoTo Son
Ders_Adi_2 = Ders_Adi_Sec.ComboBox1.Value

Dim Found_Ders As Range
Set Found_Ders = Sheets("Egitim Bilgileri").Columns("C").Find(Ders_Adi_2, LookIn:=xlValues, lookat:=xlWhole)
Ders_Adi_Row = Found_Ders.Row

Ders_Sheet_Adi = Worksheets("Egitim Bilgileri").Cells(Ders_Adi_Row, 1).Value
Ders_Satir_bul = Found_Ders.Row

' Ders_Satir_bul degeri, aratilan egitimin, "Egitim_Bilgileri" sayfasindaki satir numarasidir.

Worksheets("Ders_TEMP").Visible
Worksheets("Egitim Bilgileri").Visible
Worksheets(Ders_Sheet_Adi).Visible
Worksheets(Worksheet_Bilgiler).Cells(Ders_Satir_bul, 3).Copy
Application.ScreenUpdating = False
Worksheets("Ders_TEMP").Activate
Worksheets("Ders_TEMP").Select
Worksheets("Ders_TEMP").Range("A2:J2").Select
ActiveSheet.Paste
Worksheets("Ders_TEMP").Range("A49:J49").Select
ActiveSheet.Paste
Worksheets("Ders_TEMP").Range("A96:J96").Select
ActiveSheet.Paste

1 个答案:

答案 0 :(得分:0)

对不起,我的错,我忘了在.visible statements之后加上“= True”。