+ Reply to Thread
Results 1 to 6 of 6

Macro to delete set columns and rows

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    London,England
    MS-Off Ver
    2010
    Posts
    95

    Macro to delete set columns and rows

    Just wondering if anyone can upload a macro to delete certain rows and columns.

    I will assign it to a button on sheet 1 and it needs to delete columns A:D,I:J and L:M on a sheet named 'imported data'.

    I also need it to delete rows 1-5 on the same sheet.

    Really appreciate the help.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro to delete set columns and rows

    You don't have to use variables like I have, but this will let you adjust this idea more easily. You can see where you enter the ranges, and the worksheet name. It would need to be run from the workbook with the worksheet (that's what "thisWorkbook" means).

    So, put this in a code module in that workbook and it should be fine.

    Please Login or Register  to view this content.
    Last edited by GeneralDisarray; 09-26-2014 at 11:18 AM. Reason: forgot to name the sub
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    08-26-2014
    Location
    London,England
    MS-Off Ver
    2010
    Posts
    95

    Re: Macro to delete set columns and rows

    Thanks so much. Appreciate the effort.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro to delete set columns and rows

    No problem. If this answers your question, please mark your thread [Solved].

    To do that, edit your first comment. Press "Go Advanced" and add the [Solved] prefix.

  5. #5
    Registered User
    Join Date
    08-26-2014
    Location
    London,England
    MS-Off Ver
    2010
    Posts
    95

    Re: Macro to delete set columns and rows

    Forgot to post this with the above but do you know if a way to split text in a column.

    Eg; Chiang/Kevin C MR is in column A and I need it to be split into different columns for First name, last name, Initial and Title.

    Thanks

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro to delete set columns and rows

    "Text to Columns" is a built in feature of Excel. You can try that, it's found under the Data tab on the excel ribbon. You would tell excel that the text is "delimited" by / and by space.

    A delimiter is a character that tells excel where to break apart the text.


    OR - you could use string functions to handle the values for first, last, middle initial and title.

    If the value "Chiang/Kevin C MR" is sitting in A2:

    First name is given by: =MID(A2,FIND("/",A2)+1,FIND(" ",A2)-FIND("/",A2)-1)

    Last names is given by: =LEFT(A2,FIND("/",A2)-1)

    Middle Initial is given by: =MID(A2,FIND(" ",A2)+1,1)

    Title is given by: =RIGHT(A2,LEN(A2)-FIND(" ",A2,FIND(" ",A2)+1))

+ 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. Macro to delete rows and columns
    By siroco79 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2013, 07:37 AM
  2. Macro help to search in all columns and delete rows accordingly
    By JonnyNYC90 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-20-2012, 03:44 PM
  3. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  4. Macro to delete certain rows and create columns
    By excel77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2010, 10:06 AM
  5. Using a macro to delete last 4 rows and last 2 columns which vary
    By Shirley Munro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2005, 12:05 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