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 8711627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:55:31+00:00 2026-06-13T04:55:31+00:00

I have a function that creates a Pivot Table, but I am getting an

  • 0

I have a function that creates a Pivot Table, but I am getting an error when I try to set a range that will be merged and have a title added to it.

In the below code, pivot_title_range is a ‘String’ variable, and is optional when calling the function. title_range is a ‘Range’ variable. Both lines that set the range (whether or not the users declares pivot_title_range) cause the same error.

If pivot_title_range = "" Then
    title_range = ActiveSheet.Range("B3:E4")
Else
    title_range = ActiveSheet.Range(pivot_title_range)
End If

Here is the error that I am getting –

Run-time error '91':
Object variable or With block variable not set

If required, here is a Pastebin of the full function – http://pastebin.com/L711jayc. The offending code starts on line 160.

Is anybody able to tell me what I am doing wrong? 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-06-13T04:55:33+00:00Added an answer on June 13, 2026 at 4:55 am

    You need to use

    If pivot_title_range = "" Then
        Set title_range = ActiveSheet.Range("B3:E4")
    Else
        set title_range = ActiveSheet.Range(pivot_title_range)
    End If
    

    Because you defined title_range as range – and this is an Object 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two functions, one that creates a table like so: function return_formatted_results(result_no,addy,title,own_comment) {
I have this great function that parses a field into a pivot table consisting
I need to create a pivot table in R that will have text values
I have a function that creates a binary sha1, but I need a result
I have a function that creates time intervals between two time marks. The function
I have a function that creates zip files when passed an array of files
I have a function that creates a course. I am trying to get the
I have a function that creates a 2D vector void generate(int n) { vector<
I have a Matlab function that creates a cell array with matrixes inside. It
Lets say I have a recursive function that creates lists within lists. It return

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.