+ Reply to Thread
Results 1 to 4 of 4

range selection rows code replace

Hybrid View

  1. #1
    Registered User
    Join Date
    04-26-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2003 2007
    Posts
    69

    range selection rows code replace

    Sheets("Main").Select
        Range("A1301:F2101,S1301:X2101,AD1301:AI2101,AO1301:AT2101,AZ1301:BE2101,BK1301:BP2101,BV1301:CA2101").Select    
        Selection.ClearContents
        Range("A1301").Select
    cell M13 = 1301
    cell M14 = 2101

    how to code this so i can enter the start row and end row in M13 and M14,
    Last edited by bezbid; 01-20-2015 at 06:04 AM.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: range selection rows code replace

    Try this
    Sub Test()
        Dim StartRow As Long, EndRow As Long
        StartRow = 1301
        EndRow = 2101
        Sheets("Main").Select
        Range("A" & StartRow & ":F" & EndRow & ",S" & StartRow & ":X" & EndRow & ",AD" & _
        StartRow & ":AI" & EndRow & ",AO" & StartRow & ":AT" & EndRow & ",AZ" & StartRow & _
        ":BE" & EndRow & ",BK" & StartRow & ":BP" & EndRow & ",BV" & StartRow & ":CA" & EndRow & "").Select
        Selection.ClearContents
        Range("A" & StartRow).Select
    End Sub

  3. #3
    Registered User
    Join Date
    04-26-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2003 2007
    Posts
    69

    Re: range selection rows code replace

        
    Sub Test()
        Dim StartRow As Long, EndRow As Long
        StartRow = Range("M13").Value                                           
        EndRow = Range("M14").Value
        Sheets("Main").Select
        Range("A" & StartRow & ":F" & EndRow & ",S" & StartRow & ":X" & EndRow & ",AD" & _
        StartRow & ":AI" & EndRow & ",AO" & StartRow & ":AT" & EndRow & ",AZ" & StartRow & _
        ":BE" & EndRow & ",BK" & StartRow & ":BP" & EndRow & ",BV" & StartRow & ":CA" & EndRow & "").Select
        Selection.ClearContents
        Range("A" & StartRow).Select
    End Sub
    Thank you

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: range selection rows code replace

    you're welcome thanks for the feedback

+ 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. Hide rows in range 2 based on filter selection in range 1
    By gtol in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-28-2012, 02:09 PM
  2. Selection.Replace replaces in entire workbook despite Range.Select
    By robapodaca in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2011, 08:23 PM
  3. code selection range
    By pichai in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-16-2008, 09:13 PM
  4. Replace Values in range selection
    By Terri in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2005, 08:30 PM
  5. VBA Code for selection rows
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2005, 09: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