Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:07:52+00:00 2026-05-27T05:07:52+00:00

I created a subroutine to store all the cells in a worksheet in an

  • 0

I created a subroutine to store all the cells in a worksheet in an object called “CNrng3”.

Sub GetCLRange()
Dim CLrng1 As Range
Dim CLrng2 As Range
Sheets("Cancel").Activate
Set CLrng1 = Cells.Find("*", [a1], , , xlByRows, xlPrevious)
Set CLrng2 = Cells.Find("*", [a1], , , xlByColumns, xlPrevious)
If Not CLrng1 Is Nothing Then
    Set CLrng3 = Range([a1], Cells(CLrng1.Row, CLrng2.Column))
Application.Goto CLrng3
Else
    MsgBox "sheet is blank", vbCritical
End If
End Sub

Now, I want to reference this object to create a pivot with the data:

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    CLrng3.Cells, Version:=xlPivotTableVersion12).CreatePivotTable _
    TableDestination:="CancelSummary!R1C1", TableName:="CancelPivot", _
    DefaultVersion:=xlPivotTableVersion12

The issue is that I’m getting “Type Mismatch Error 13” when I run this part of the code. Does anyone have an idea why I may be receiving this error and how to fix it?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:07:53+00:00Added an answer on May 27, 2026 at 5:07 am

    If you try recording the code with the macro recorder you will see that the SourceRange expects to see an address such as "Cancel!R1C1:R10C5" which includes the sheet name

    So rather than

    SourceData:= CLrng3.Cells

    try

    SourceData:=(Clrng3.Parent.Name & "!" & Clrng3.Address)

    which returns in three parts

    1. “Cancel” (as the name of the parent of your range)
    2. “!”
    3. and something like A1:E10

    giving Cancel!A1:E10

     Sub GetCLRange()
        Dim CLrng1 As Range
        Dim CLrng2 As Range
        Dim Clrng3 As Range
        Sheets("Cancel").Activate
        Set CLrng1 = Cells.Find("*", [a1], , , xlByRows, xlPrevious)
        Set CLrng2 = Cells.Find("*", [a1], , , xlByColumns, xlPrevious)
        If Not CLrng1 Is Nothing Then
            Set Clrng3 = Range([a1], Cells(CLrng1.Row, CLrng2.Column))
            ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
                                              ("'" & Clrng3.Parent.Name & "'!" & Clrng3.Address), Version:=xlPivotTableVersion12).CreatePivotTable _
                                              TableDestination:="CancelSummary!R1C1", TableName:="CancelPivot", _
                                              DefaultVersion:=xlPivotTableVersion12
            Application.Goto Clrng3
        Else
            MsgBox "sheet is blank", vbCritical
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using: Excel 2007/Win 7 First, I created a subroutine to find the dynamic range
Created Private Key & Self signed certficate in a Key Store keytool -genkey -alias
Created an OpenGraph action and object. Trying to submit my action. When I click
Here is what I have as VBScript Subroutine: sub buildChildAdminStringHierarchical(byval pAdminID, byref adminString) set
I have a subroutine called debug I use in my code. It basically allows
I would like to create subroutine with a dynamically created regxp. Here is what
How should I define a Moose object subroutine after its initialization? I'm writing an
VB.NET 2010, .NET 4 Hello all, I have a System.Timers.Timer object that does some
I am trying to create the subroutine mypush with similar functionality of inbuilt push
Created .NET WCF service, tested it - works. Generated schemas from Data and service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.