Results 1 to 6 of 6

Applying Macros to Selections only.

Threaded View

  1. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Applying Macros to Selections only.

    Eli,

    So are you trying to figure out how to remove a column, but only the rows in the currently selected area? Do you select the entire range that the macro modifies before starting your macro?

    If it is based on an area you manually highlight before processing, then this might be what you are looking for? If the range is pre-defined, just replace "Set rng = Selection" with "Rng = the range you want"

    Sub delete_column_in_row_range()
    Dim rng As Range
    Dim frow, lrow As Integer 'first and last rows of your selected range
    Set rng = Selection ' this takes selected area to figure out the rows
    frow = rng.Cells(1, 1).Row 'first row in selected range
    lrow = rng.Cells.Rows.Count + frow - 1 'last row in selected range (row# on the sheet)
    Range("A" & frow, "A" & lrow).Select 'selects column A within your original selection
    Selection.Delete shift:=xlToLeft 'removes the selected cells and shifts the rest to the left
    End Sub
    Last edited by Arkadi; 02-13-2014 at 02:16 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Worksheet Selections in Macros
    By Duke Carey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-06-2005, 09:05 PM
  2. [SOLVED] Worksheet Selections in Macros
    By Duke Carey in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-06-2005, 07:05 PM
  3. [SOLVED] Worksheet Selections in Macros
    By Karen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  4. [SOLVED] Worksheet Selections in Macros
    By Karen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 PM
  5. [SOLVED] Worksheet Selections in Macros
    By Karen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM

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