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

  • Home
  • SEARCH
  • 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 8106919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:36:33+00:00 2026-06-06T00:36:33+00:00

I call from a spreadsheet module a function that does some processing in another

  • 0

I call from a spreadsheet module a function that does some processing in another sheet and returns an integer. I then want to write that integer in a cell in the sheet from where the function has been called. I receive an error 400, I guess I do not correctly handle the switching between the sheets.

Could you help me with that?

Function lastNonZero(Rng As Range) As Integer

 i = 19
 Do While ActiveCell.Value = 0
   ActiveCell.Offset(0, -1).Activate
   i = i - 1
 Loop
lastNonZero = i
End Function

Extract from the Sub, located in Sheet A’s module:

For j = startRow To startRow + (nRows - 1)
        Worksheets("B").Select
        Range("Y" & j).Activate
        k = lastNonZero(Worksheets("B").Range("Y" & j))
        Worksheets("A").Range("BZ" & j) = k
Next j
  • 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-06T00:36:35+00:00Added an answer on June 6, 2026 at 12:36 am

    Try to replace the Range("Y" & j) line with:

    Worksheets("B").Range("Y" & j).Activate
    

    When you call Range(xxx) in a Sheet’s module, it refers to a range in that sheet, whether it is selected or not. But if the sheet is not selected and you try to select/activate the range, it will return an error because you can’t select a range on a sheet that is not the active sheet.

    ps: that does not change the fact that on the next line (k = lastNonZero(Worksheets("B").Range("Y" & j))), the argument is not used in the lastNonZero function).

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

Sidebar

Related Questions

Ok so I simply call from mysql some text, and then I run it
i just got a call from Hosting company, they claimed that my application creates
I need to call from my code for some other program . And I
Im making an asynchronous call from a class to another. Here is my actual
I'm trying to call from C# a function in a custom DLL written in
I'm attempting to build a method call from strings that have been passed into
I want to initiate a call from my Twilio number to a customer and
We recently got a call from one of our clients, complaining that their site
how can i make call from my application to particular no. Give me some
call from main matrix_multiplication(arrayA,arrayB,row1,col1,col2); function definition float matrix__multiplication(float **arrayA,float **arrayB,int row1,int col1,int col2) {

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.