+ Reply to Thread
Results 1 to 14 of 14

change last cell in column

  1. #1
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63

    change last cell in column

    Well another question, thanks to mudraker I have this code
    Please Login or Register  to view this content.
    It works great for what i want to do except the cell b38 will not always be b38 it will however be the last cell in column b. any ideas?

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by jj33002
    Well another question, thanks to mudraker I have this code
    Please Login or Register  to view this content.
    It works great for what i want to do except the cell b38 will not always be b38 it will however be the last cell in column b. any ideas?
    Hi

    to find the last used cell in column B try
    Please Login or Register  to view this content.
    and to use that would be Range("B" & iLastRow). etc

    hth
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Please Login or Register  to view this content.
    If you update your code to what's shown above, does that work?

    UPDATE: Bryan pre-copied my reply.
    Last edited by Paul; 04-03-2007 at 11:42 PM.

  4. #4
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    I attatched a copy of the worksheets I have been using, for some reason when I put it in there it doesnt work, but i can take a new plain worksheet and put some dummy numbers and a formula in there and it works.
    Bill test.zip

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Can you tell me what exactly you're trying to make this code do? Are you trying to make the value from C38 on one sheet into another sheet? Just looking at your worksheet isn't making it clearer to me (maybe it's too late and my brain is asleep.)


  6. #6
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    What it does is take the total in column B at the bottom of the page and at the first of the month it changes that formula into just the number value instead of a formula. That way it the total in B for let's say the month of March will not keep changing now that it is april. if the cell that gives you your total in column b didnt move then I wouldn't have this problem but sometimes it moves down a couple lets say from row 38 to 39 or 40. I hope this makes it clearer.

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    I think I found the problem..

    In column B, row 54 you have the word "Total". It is making this the "iLastRow", and when the macro runs it's simply replacing "Total" with "Total". You need it to always find the last row in column B, so move "Total" to another column (C, for instance). Select all cells from B39 to B60 (or thereabouts) and click Delete just to be sure that range is empty.

    Save your file and re-open it. The Workbook_Open macro should change the formula in B38 to the value, 272.96.

    Let me know how that goes..

  8. #8
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    Well don't I feel like an idiot know. Thanks a lot. That seemed to have fixed my problem. I will do more extensive tests tomorrow.

    Thanks a lot

    Josh

  9. #9
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    I also found another way to help, I think..

    In cell B2 on sheets April and May, you have a formula pointing to cell B38 on the previous sheet. As you mentioned, the last row might not be 38 for a given month, so instead of '=March!B38', '=April!B38', etc., use this for cell B2 in April:

    Please Login or Register  to view this content.
    For May!B2 change the month reference to April, like so:

    Please Login or Register  to view this content.
    PS - If anyone reading this has better ideas to automatically change the month, by all means do share.

    UPDATE: Those are array formulas.. you must press CTRL+SHIFT+ENTER after typing them, not just ENTER.
    Last edited by Paul; 04-04-2007 at 01:09 AM.

  10. #10
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    All right I will try that later tonight when I get home. Thanks alot. I will let you know how it works out.

    Josh

  11. #11
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    I can't get that formula to work right.
    Please Login or Register  to view this content.
    It just gives me the value of b2. I can change the formula to b38 and it will give it to me but whenever it is in b39 it just says 0. I have been trying a few things and still no result. did I do something wrong.


    Nevermind when I pushed CTRL+SHIFT+ENTER it worked. Woops.

    Thanks a lot

    Josh
    Last edited by jj33002; 04-04-2007 at 10:37 PM.

  12. #12
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    After typing the formula, did you press CTRL+SHIFT+ENTER? It is required of this type of formula (array formulas).

    If you're not sure, go to that cell, press F2 to activate the cell, then press CTRL+SHIFT+ENTER.

    If you only press ENTER, it will return the first value in the array B2:B50, which is why you're seeing the value from B2.

  13. #13
    Registered User
    Join Date
    12-31-2005
    Location
    Atkins, Arkansas
    MS-Off Ver
    2013
    Posts
    63
    I really appreciate the help. And the quick responses. Maybe I will have another brain teaser for you some other time.


    Josh

  14. #14
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    My pleasure. Glad we could help you out.

+ 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