+ Reply to Thread
Results 1 to 6 of 6

Find Last Filled Cell, Negate it, determine another cell and subtotal a column

  1. #1
    Registered User
    Join Date
    06-20-2007
    Posts
    9

    Last Cell, Negate, Subtotal / Passing File Reference in User Input

    Friends,

    Here's what I'm trying to do. I need to find the last value in column K, negate its value (multiple by -1).

    Now after negating it, if the value is

    >0, corresponding cell in column I should be 10
    <0, corresponding cell in column I should be 20

    And then I want to do a subtotal for column K and pop up a msg stating the subtotal. I don't want to store the subtotal anywhere on the sheet, just needs to be in the msg box.

    Any help would be great appreciated !!!
    Last edited by kerl; 07-30-2007 at 04:54 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Kerl,

    Here is a macro to do what you want. The subtotal starts at K2.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    06-20-2007
    Posts
    9
    Thanks Leith Ross! The code works flawlessly

    BTW, if I'm using the following code for the user to locate a file on the PC, how do I give the command to close the file?

    Please Login or Register  to view this content.
    I tried doing the following but it won't work.

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Kerl,

    Simply close the Workbook...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    06-20-2007
    Posts
    9
    even that doesn't work and gives me a runtime error (snapshot attached). And it highlights the line

    Please Login or Register  to view this content.
    Attached Images Attached Images

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Kerl,

    Since you're getting a "subscript out of range" error, you need to check the value of your variable. I am guessing sFileName is not formed properly or possibly empty.

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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