+ Reply to Thread
Results 1 to 3 of 3

VBA is selecting the wrong columns???

  1. #1
    Forum Contributor
    Join Date
    04-27-2009
    Location
    Dallas, TX
    MS-Off Ver
    Office 365
    Posts
    215

    VBA is selecting the wrong columns???

    I'm doing a simple clean up of a file that gets exported from our system. Since the clean up is so straight forward, I just did a record macro. At one point I have the macro select columns G:J and remove those columns. Then I tell the macro to select columns I:J and delete those. But instead of selecting I:J, it selects G:J again and deletes the data I needed that is sitting in G:H. I tried inserting a step where the macro selected a completely different cell, and THEN go select I:J, but sure enough, it went back and selected G:J again and deleted that data. Has anyone ever seen this before?

    Here is my code:

    Please Login or Register  to view this content.
    Last edited by mvparker79; 12-11-2019 at 03:51 PM. Reason: Solved

  2. #2
    Forum Contributor
    Join Date
    04-27-2009
    Location
    Dallas, TX
    MS-Off Ver
    Office 365
    Posts
    215

    Re: VBA is selecting the wrong columns???

    merged cells....duh!!!!

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA is selecting the wrong columns???

    Yes, the dreaded merged cells.

    And

    When deleting it is best to start from the end and work your way back (Columns) or up (Rows).
    Once when deleting G to J, K becomes G, L becomes I, M becomes J and N becomes K.

    Work at it to minimize selecting.
    This does the same
    Please Login or Register  to view this content.
    as this
    Please Login or Register  to view this content.
    Same range twice?
    Please Login or Register  to view this content.
    Maybe like this
    Please Login or Register  to view this content.
    Start with this and let us know how you're making out.
    If still problems, let us know what kind.

+ 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. [SOLVED] Locking wrong columns
    By ivath0 in forum Excel General
    Replies: 8
    Last Post: 07-16-2019, 08:29 AM
  2. [SOLVED] Macro is selecting the wrong range
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-17-2015, 10:08 AM
  3. [SOLVED] Selecting all data in specific columns without selecting adjacent column.
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2014, 02:20 AM
  4. Selecting all data in specific columns without selecting adjacent column.
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2014, 03:50 PM
  5. [SOLVED] Issue w/ Current Region, Select 3 Columns of Data without selecting adjacent columns
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2014, 02:57 PM
  6. [SOLVED] =INT(COLUMNS Formula, wrong column
    By IKZOUHETNIETWETEN in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-12-2014, 11:16 AM
  7. Comparing two columns. What's wrong with this?
    By egibberate in forum Excel General
    Replies: 2
    Last Post: 07-17-2008, 02:52 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