+ Reply to Thread
Results 1 to 10 of 10

VBA Offset acting strange?

  1. #1
    Forum Contributor
    Join Date
    05-29-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    143

    VBA Offset acting strange?

    Maybe there's something I don't know, but I'm using Offset to find values in one cell and export them to another cell. There have been a few times, where Offset is not what I would expect. For instance, in the code:

    Please Login or Register  to view this content.
    The second argument for Offset sometimes isn't what I would expect it to be and I'm not sure why this is. Hopefully someone can shed some insight into this? Thanks
    Attached Files Attached Files
    Last edited by Blackhawks; 11-22-2016 at 11:04 AM.

  2. #2
    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: VBA Offset acting strange?

    Hi Blackhawks

    Don't know if this is the issue...can't test.

    You're missing a Dot (.) here...
    Please Login or Register  to view this content.
    Should be...
    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.

  3. #3
    Forum Contributor
    Join Date
    05-29-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    143

    Re: VBA Offset acting strange?

    I've tried adding
    Please Login or Register  to view this content.
    But it doesn't change anything. I'll try uploading some data tomorrow to test it out. I've used Range without the Dot before, do you know why this would matter?

  4. #4
    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: VBA Offset acting strange?

    Hi Blackhawks
    I've used Range without the Dot before, do you know why this would matter?
    Yes...way to late tonight for me to explain...in bed...

    Try more "missing Dots" (.)

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA Offset acting strange?

    Hi

    Do you have any merged cells in your worksheet?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Forum Contributor
    Join Date
    05-29-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    143

    Re: VBA Offset acting strange?

    No, no merged cells. The only thing that I could think of is that I used a VBA script to pull the data from a csv file. So It goes something like this, I imported the data from a csv file. Filtered it using a vba script to go into another worksheet (Containing all sales), now I'm using the current vba script to pull only select data into a new worksheet. Perhaps the data is retaining old reference data?

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA Offset acting strange?

    Are you saying that the data is not where you expect, or that Offset(0, 15) is actually referring to a cell 4 to the right of the ALS cell? The latter is impossible so I would surmise that your import process has put data where you do not expect it to be.

  8. #8
    Forum Contributor
    Join Date
    05-29-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    143

    Re: VBA Offset acting strange?

    The latter. For instance, Offset(0, 15) actually refers to what (I would think) should be Offset(0, 4). What can I do about this? Because the Import process worked (i.e., all of the cells are where they should be with the exception of one weird quirk that I noticed on import, but I dismissed it). Is there a way to clear any underlying reference data? I'm pretty lost and I'm afraid I don't know how to get this done.

    Does anyone know of any websites that you can pay to get excel help? I need to complete this and although I technically have it working right now, I'm afraid of giving it to my client because I don't know it will crash or bug out later. I want it to be solid.

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA Offset acting strange?

    This covers about all necessary dots in your code so miscounting shouldn't arise anymore.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  10. #10
    Forum Contributor
    Join Date
    05-29-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    143

    Re: VBA Offset acting strange?

    Bakerman2 - thank you!! This worked. Do you mind telling me why it worked exactly? I tried adding dots to Range and Rows, but it's adding SendToMRP.Rows that made it work.

    And thank you to everyone else that helped me with this!

+ 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. Excel acting strange after macro completes - ActiveSheet not shown
    By Zars01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2016, 06:21 PM
  2. [SOLVED] Dynamic named range - INDEX - acting strange!
    By Geoff. in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2015, 07:47 PM
  3. [SOLVED] "End" button acting strange
    By dcoates in forum Excel General
    Replies: 0
    Last Post: 08-08-2014, 03:27 PM
  4. Subroutine is halted, but Excel acting strange - Cells don't appear selected...
    By paulcola in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 05-05-2013, 08:00 PM
  5. Replies: 3
    Last Post: 05-27-2009, 08:50 AM
  6. Excel acting strange
    By mrgeek2u in forum Excel General
    Replies: 5
    Last Post: 06-07-2007, 04:54 PM
  7. [SOLVED] Strange offset fault
    By ramcsir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2005, 11:06 AM

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