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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:34:36+00:00 2026-06-09T15:34:36+00:00

I am trying to use a function that will allow me to import a

  • 0

I am trying to use a function that will allow me to import a range from a previous worksheet. I am not sure that my current macro allows this. I can call the previous worksheet manually, but not with the function that I have.

Here is the function that works fine when I manually input the worksheet name:

=IFERROR(VLOOKUP(D3,Aug9Daily!$D$3:$F$50,3, FALSE),"")

Here is the function that I am attempting to use:

=IFERROR(VLOOKUP(D3,NextSheetName()$D$3:$F$50,3, FALSE),"")

This is the VBA that I am using for the NextSheetName macro:

Function NextSheetName(Optional WS As Worksheet = Nothing) As String
    Application.Volatile True
    Dim S As String
    Dim Q As String
    If IsObject(Application.Caller) = True Then
        Set WS = Application.Caller.Worksheet
        If WS.Index = WS.Parent.Sheets.Count Then
            With Application.Caller.Worksheet.Parent.Worksheets
                Set WS = .Item(1)
            End With
        Else 
            Set WS = WS.Next
        End If
        If InStr(1, WS.Name, " ", vbBinaryCompare) > 0 Then
            Q = "'"
        Else
            Q = vbNullString
        End If
    Else
        If WS Is Nothing Then
           Set WS = ActiveSheet
        End If
        If WS.Index = WS.Parent.Worksheets.Count Then
            With WS.Parent.Worksheets
               Set WS = .Item(1)
            End With
        Else
            Set WS = WS.Next
        End If
        Q = vbNullString
    End If
    NextSheetName = Q & WS.Name & Q
End Function

What am I doing wrong? Is there a better way to select a range from another worksheet dynamically?

  • 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-09T15:34:37+00:00Added an answer on June 9, 2026 at 3:34 pm

    Try this to see if it works for you to fix your function’s output:

    NextSheetName =  Q & WS.Name & Q & "!"
    

    And then you will need to concatinate the output inside of an indirect function like this:

    =IFERROR(VLOOKUP(D3,INDIRECT(NextSheetName() & "$D$3:$F$50"),3, FALSE),"")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to define a function that will allow me to get a value
I'm trying to create a function so that =processCells(A1:A10) will take the range of
I'm trying to use Seq.cache with a function that I made that returns a
I'm trying to write a function that would use its first argument, then send
I'm trying to use the function below to get a DIV to slide-out from
I am trying to use this function from a COM API which enables the
I am trying to add functionality to a webpage that will allow the user
I'm trying to create a web application that will allow a user to post
I am trying to make a query in Codeigniter that will allow a user
I'm trying to write a regex function that will identify and replace a single

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.