+ Reply to Thread
Results 1 to 3 of 3

2010 Macro Issue - deleting columns and rows

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    dallas, tx
    MS-Off Ver
    Excel 2007
    Posts
    36

    2010 Macro Issue - deleting columns and rows

    I wrote this macro to delete specific columns and rows from a workbook when I launch it. Its pretty straight forward, however whenever I run it in Excel 2010, it deletes basically the first 10 columns instead of the ones I designated. Any recommendations anyone?

    Sub Contributions()
    '
    ' Contributions Macro

    Columns("L:M").Select
    Range("M1").Activate
    Selection.Delete Shift:=xlToLeft
    Columns("G:H").Select
    Range("G2").Activate
    Selection.Delete Shift:=xlToLeft
    Columns("B:B").Select
    Range("B2").Activate
    Selection.Delete Shift:=xlToLeft
    Rows("1:5").Select
    Selection.Delete Shift:=xlUp
    Columns("A:J").EntireColumn.AutoFit

    End Sub

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: 2010 Macro Issue - deleting columns and rows

    Hi Scalpel,

    You can do what you want with two basic types of statements:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Change the Column Letter(s) or Row Number(s) and it should make more sense.

    When you record a macro it doesn't know exactly where you are going so it throws in stuff like Range("B2").Activate which you can remove to accomplish your goal.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    12-10-2013
    Location
    dallas, tx
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: 2010 Macro Issue - deleting columns and rows

    Thanks, worked like a charm!

+ 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. Replies: 10
    Last Post: 06-07-2018, 04:16 PM
  2. Code/Macro for deleting empty columns and rows.
    By gautamacharya in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2014, 01:49 PM
  3. Deleting ROWS via VBA...Excel 2010
    By rlc2120 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-19-2013, 08:12 PM
  4. [SOLVED] Align Rows - Compare Columns (Issue with shg's alignkeys macro)
    By Massael in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 10-22-2013, 08:40 PM
  5. Deleting Rows Excel 2010
    By extrapulp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-27-2010, 08:51 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