简体   繁体   中英

Cannot identify source of "Type Mismatch" Error

The following macro gives a type mismatch error when run, and I cannot see where there is one. I would appreciate any advice on this issue:

Sub Add_W()
Dim cel As Range
Dim selectedRange As Range
Dim WCount As Integer

Set selectedRange = ("C4:C20")

Set WCount = 0

For Each cel In selectedRange.Cells
    Wname = cel.Text

    With ThisWorkbook
        .Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = Wname + " Table"
        .Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = Wname + " Plots"
    End With

    Sheets(Wname + " Table").Select

    Sheets("Report").Select
    If IsEmpty(Range("B5")) Then
        Rows(5).Insert shift:=xlShiftDown
    End If
    Range("B5") = Wname
    WCount = WCount + 1

    Sheets("Input").Select
    Range("U" & WCount + 1) = Wname

    Sheets(Wname + " Plots").Select
Next cel


End Sub

使用Set selectedRange = ActiveSheet.Range("C4:C20")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM