+ Reply to Thread
Results 1 to 13 of 13

Setting the Range of a Worksheet Function using the Location of the overall Function Input

  1. #1
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Setting the Range of a Worksheet Function using the Location of the overall Function Input

    How do I set the Range for a sheet function using the location of the overall function input? I've included a screenshot of my code below. I'm trying to set the range of the Product Function according to the location of the initial function input "inventoryType".

    Capture.PNG

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,014

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    I'm not clear on the wording of your question but I think you just want this:
    Please Login or Register  to view this content.
    A screenshot of code is not particularly useful. It's easier to just copy the code and paste it into your post. That way we can try to compile it, run it, and edit it. Use CODE tags when pasting code. There are two ways to add code tags. One is to select the code part of the text so it is highlighted, then press the "#" button in the edit controls. The other is to simply type in the tags:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Included the code below. To reword my question, how do I turn Cells(j-1, k+3), Cells(n, k+3) into a Cell Range (e.g. A1:A5) for the WorksheetFunctionProduct() to use?

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Can you upload the spreadsheet, and describe what is happening, as well as what you want to happen?

    Just looking at the code, I don't see why it wouldn't work as is.

  5. #5
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Where can I upload the Excel Spreadsheet so I can link it? I don't see an attachment option on this post.

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Click on 'Go Advanced', and you should then see a paperclip icon for uploading.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,014

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Quote Originally Posted by mgs73 View Post
    Click on 'Go Advanced', and you should then see a paperclip icon for uploading.
    The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,014

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Quote Originally Posted by shouwiz View Post
    how do I turn Cells(j-1, k+3), Cells(n, k+3) into a Cell Range (e.g. A1:A5) for the WorksheetFunctionProduct() to use?]
    You are already using a perfectly good range for Product to use.

    Range(Cells(j - 1, k + 3), Cells(n, k + 3))

    Not a thing wrong with that.

  9. #9
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Alright you're right, there was nothing wrong with the equation. I declared my variables incorrectly. They were all long, so I kept getting an integer output, instead of the decimals I needed. I assumed that I just built the equation wrong, when in fact, I just had to change my variables to doubles. Thanks for the help guys!

  10. #10
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Oh, since it's my first solved post, how do I set the tag to [SOLVED]?

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,014

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,014

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Quote Originally Posted by shouwiz View Post
    Alright you're right, there was nothing wrong with the equation. I declared my variables incorrectly. They were all long, so I kept getting an integer output, instead of the decimals I needed. I assumed that I just built the equation wrong, when in fact, I just had to change my variables to doubles. Thanks for the help guys!
    If you need a real result, then the only thing you should change to Double is the return type for the function. All your local variables should still be Long.

  13. #13
    Registered User
    Join Date
    09-04-2018
    Location
    Minnesota
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Setting the Range of a Worksheet Function using the Location of the overall Function I

    Yup that's what I did, thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using offset function to select a range of cells based on active cell location
    By laxminarayana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2017, 07:49 AM
  2. Setting each cell in range with a function
    By calebii in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2015, 04:28 PM
  3. Replies: 15
    Last Post: 09-10-2013, 05:31 AM
  4. [SOLVED] Need to specify a function range that gets offset depending on cell location
    By Spirods in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-13-2013, 04:52 AM
  5. Percentile function - help setting range + conditional
    By R.Koenig in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-19-2011, 09:02 AM
  6. Setting Range.Formula with custom function
    By beeawwb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2009, 11:55 PM
  7. Setting Cell Number Format With A Worksheet Function
    By jhcoxx@hotmail.com in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-16-2005, 03:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1