Добрый день,
Я хотел бы создать дубликат листа в своем документе. К сожалению, я получаю сообщение об ошибке:
Ожидаемая переменная или процедура, а не модуль
На моем текущем листе есть список со списком
Где код выглядит следующим образом:
Private Sub Cable2_Change()
Dim rng As Range
Set rng = ActiveSheet.Range("B65")
Dim ans As VbMsgBoxResult
Select Case rng
Case "CFS-PL 107"
With Sheets("hilti firestopping stores").Range("E5")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Plug").Copy
ActiveSheet.Range("G18").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-PL 132"
With Sheets("hilti firestopping stores").Range("E6")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Plug").Copy
ActiveSheet.Range("G19").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-PL 158"
With Sheets("hilti firestopping stores").Range("E7")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Plug").Copy
ActiveSheet.Range("G20").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-PL 202"
With Sheets("hilti firestopping stores").Range("E8")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Plug").Copy
ActiveSheet.Range("G21").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-CC"
With Sheets("hilti firestopping stores").Range("E9")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Cable_Collar").Copy
ActiveSheet.Range("G22").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-D 25"
With Sheets("hilti firestopping stores").Range("E10")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Cable_Disc").Copy
ActiveSheet.Range("G23").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-SL GA1"
With Sheets("hilti firestopping stores").Range("E11")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Sleeve").Copy
ActiveSheet.Range("G24").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-SL GA2"
With Sheets("hilti firestopping stores").Range("E12")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Sleeve").Copy
ActiveSheet.Range("G25").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-SL GA3"
With Sheets("hilti firestopping stores").Range("E13")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Sleeve").Copy
ActiveSheet.Range("G26").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-F FX"
With Sheets("hilti firestopping stores").Range("E14")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Foam_Blue").Copy
ActiveSheet.Range("G27").PasteSpecial
Selection.Name = "Firestop"
Case "CP 620"
With Sheets("hilti firestopping stores").Range("E15")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Foam_Red").Copy
ActiveSheet.Range("G28").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-BL"
With Sheets("hilti firestopping stores").Range("E16")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Firestop_Block").Copy
ActiveSheet.Range("G29").PasteSpecial
Selection.Name = "Firestop"
Case "CFS-SP SIL"
With Sheets("hilti firestopping stores").Range("E17")
.Value = .Value + 1
End With
Worksheets("hilti firestopping stores").Shapes("Silicone_Sealant").Copy
ActiveSheet.Range("G30").PasteSpecial
Selection.Name = "Firestop"
Case "Remove"
ans = MsgBox("Do you want to remove all firestopping elements with their values?", vbQuestion + vbYesNo)
If ans = vbYes Then
Sheets("hilti firestopping stores").Range("E5:E17").ClearContents
Call Firestopshapes
End If
End Select
End Sub
Это код моего списка в выпадающем списке. Ниже у меня есть другой код для создания нового листа:
Sub CablesSheet()
Dim I As Long
Dim xNumber As Integer
Dim xName As String
Dim xActiveSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
Set xActiveSheet = ActiveSheet
xNumber = InputBox("Enter number of times to copy the current sheet")
For I = 1 To xNumber
xName = ActiveSheet.Name
xActiveSheet.Copy After:=ActiveWorkbook.Sheets("Cables (Second Floor)")
ActiveSheet.Name = "Cables (Third Floor)"
Next
xActiveSheet.Activate
Application.ScreenUpdating = True
End Sub
Я нашел ответ здесь:
Что делает ключевое слово Call в VB6?
где я обнаружил, что нехорошо использовать оператор Call
.
Я использовал его один раз в своем коде:
Call Firestopshapes
Как я могу решить эту проблему?