+ Reply to Thread
Results 1 to 5 of 5

Issue with selecting columns via macros

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    2010
    Posts
    43

    Issue with selecting columns via macros

    Hi everyone,

    I'm working on a macro that does a fair amount of formatting & removing of columns. I've got an issue when selecting columns, instead of just selecting one column a couple are being selected but I don't understand why. Any help would be greatly appreciated.

    Here's the first instance where it goes wrong, the first bit of code works fine but I've put it in so you can see that I've selected the worksheet. Instead of changing the one column to text it changes a couple of columns.

    Please Login or Register  to view this content.
    Thanks
    Jo

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Issue with selecting columns via macros

    Instead of using Select/Selection try explicitly referring to the column(s).

    Which column(s) do you want to format?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Issue with selecting columns via macros

    Obviously, this is a recorded macro.
    I can reduce your code, but I'm still not sure what you are trying to accomplish.
    You have this line of code ->> Selection.EntireRow.Delete
    What row are you deleting? Because as the code is written, it will delete the same row where the data was just pasted.

    Here's a slight mod to your code (it can be reduced further), but we'd like to know wht you are trying to do so you get what you need.
    Please Login or Register  to view this content.
    Last edited by Jim885; 11-10-2014 at 05:57 PM.
    If I helped in any way, please click the star

  4. #4
    Registered User
    Join Date
    06-26-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    2010
    Posts
    43

    Re: Issue with selecting columns via macros

    Thanks Jim & Norie for your quick replies! I really appreciate it.

    From your comments I managed to trim my code right down and get it to work. The "select" function seemed to be causing a lot of grief but the last time I used this piece of code I had no problems.

    What I was trying to do was copy a chunk of data from one sheet to another then remove the header, this data would vary in length but would always be contiguous.
    Then I wanted to change the format of one of the columns.

    Please Login or Register  to view this content.
    Last edited by Jo2710; 11-12-2014 at 08:48 PM.

  5. #5
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Issue with selecting columns via macros

    OK.
    Glad you got it solved.

+ 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] 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
  2. 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
  3. [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
  4. Issue Selecting a Dropdown from IE using VBA
    By parthisiva10 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2013, 04:00 PM
  5. Cell Selecting issue
    By Dr_Dude in forum Excel General
    Replies: 1
    Last Post: 10-18-2011, 01:04 PM

Tags for this Thread

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