+ Reply to Thread
Results 1 to 14 of 14

Can't get offset to work

  1. #1
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Can't get offset to work

    All day I have been reading my textbook, looking in MSExcel help, and doing online searches with no success to find out more about the offset function. Below I am posting my code, you probably will find it very simple and I hope you don't laugh at me. Anyway I cannot get the offset function to work. The results of this sub is that it prints the numbers (one at a time, in "A2" on Sheet3. I have a MsgBox which stops it each For each . . . it goes 1 then 2, then 3, etc. up to the correct number of days in the month that I choose. But they are all in the same box, in A2, right where I want it to start. But of course I want the numbers to fill in the cells A2 & below A2 instead of replacing the one last in A2.

    Can any of you smart people find what I did wrong?

    Thank you very much!

    Betty


    Option Explicit

    Please Login or Register  to view this content.
    Last edited by lizpete; 01-07-2013 at 11:16 AM. Reason: code tags

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,643

    Re: Can't get offset to work

    Since your index variable, i, starts at 1, you can use:
    Please Login or Register  to view this content.
    (in this case)
    Last edited by protonLeah; 01-06-2013 at 10:14 PM.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    Please Login or Register  to view this content.

    Moderator's Note: Welcome to the forum, Codes should be enclosed with code tags. Select the code then hit the "#" sign. I'll do it for now. Thank you for joining the community.
    Last edited by vlady; 01-06-2013 at 10:35 PM.

  4. #4
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    Maybe I did something wrong. You can see your suggestion in the code. It *did* start in A1 this time, with a 0 but the other numbers all appeared in A2 and rotated through all of them -- until 31 when it quit. (I chose the month of January.)

    Boy.

    Thank you, though, I'm sure it is something I should know.

    Betty

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    Hi Betty

    Notice the difference
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    Are you saying that in the () it should be 1, 0 ?

    Actually I tried them both and they both stayed in the cell "A2" and never filled the cells below.
    ??

    Thank you, though! :-)
    Betty

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    Hi Betty

    This
    Please Login or Register  to view this content.
    should be this
    Please Login or Register  to view this content.
    Not 1 but i
    Not tested...just looking at the code and seeing what you wish to do.

  8. #8
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    You didn't see my response? Maybe it wasn't clear.

    I tried with both i and 1 with the same effect, oddly. You would think "something" would be different.

    Oh, somehow I didn't get it posted.

    Betty

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    Hi Betty

    I have Grandson duty in the AM and am about to retire for the night. If you don't have a resolution by the morning I'll build a worksheet that emulates your issue and, hopefully, a suggested resolution.

    Good night.

  10. #10
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    Thank you very much!

    Betty

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    Hi Betty
    This code works for me
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    Now it doesn't work again. I just pasted it into my program. I put it onto a public link in my storage area -- https://files.secureserver.net/1f5icDhIlTSYW6
    password is vbacode

    so you could look at the behavior in my file if you get time with your grandson today.
    You can find it on tab A-L

    Thank you very much.

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    Hi Betty

    Look carefully at the code
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-06-2013
    Location
    Minnetonka, Minnesota USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Can't get offset to work

    I cannot believe it. It works now that I re-pasted the code. I cannot believe it. I need new glasses, I know I do. I guess the i makes the difference. Each "for each" it adds 1 to the offset. And when you put it before the "for each", that's starting it at the right place. It does make sense.

    You can see it work in the storage space now.

    I will study it more this evening just to make sure I understand it.

    Thanks for your great patience with me.

    Betty

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get offset to work

    You're welcome...glad I could help. Thanks for the Rep.

+ 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