+ Reply to Thread
Results 1 to 8 of 8

VBA how to select from a point to the end

Hybrid View

bryan444 VBA how to select from a... 11-29-2012, 10:35 AM
Richard Buttrey Re: VBA how to select from a... 11-29-2012, 10:40 AM
JosephP Re: VBA how to select from a... 11-29-2012, 10:52 AM
Richard Buttrey Re: VBA how to select from a... 11-29-2012, 11:35 AM
bryan444 Re: VBA how to select from a... 11-29-2012, 10:53 AM
bryan444 Re: VBA how to select from a... 11-29-2012, 12:08 PM
Richard Buttrey Re: VBA how to select from a... 11-29-2012, 12:10 PM
bryan444 Re: VBA how to select from a... 11-29-2012, 12:13 PM
  1. #1
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    VBA how to select from a point to the end

    Hello I'd like to clear the contents from lets say the point D2 till the end at the right

    I typed this but not working properly...
    Could somebody help??


    Range("D2").End(xlToRight).ClearContents
    Thanks a lot in advance

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA how to select from a point to the end

    Hi,

    If the range is contiguous then

    Range("D2"),Range("D2").End(xlToRight)).ClearContents
    if not

    Range("D2"),Range("D" & Columns.Count).End(xlToLeft)).ClearContents
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA how to select from a point to the end

    I reckon that should be
    Range("D2",Range("D2").End(xlToRight)).ClearContents
    and
    Range("D2",Range("D" & Columns.Count).End(xlToLeft)).ClearContents[/code]
    there's an extra ) in Richard's posted versions
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA how to select from a point to the end

    @Joseph

    Quite correct. Well spotted. That will teach me to check code rather than writing it on the fly

  5. #5
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: VBA how to select from a point to the end

    Thanks a lot!!!
    It worked!! :-)

  6. #6
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: VBA how to select from a point to the end

    Sorry RIchard

    But this
    Range("D2"),Range("D2").End(xlToRight)).ClearContents
    Still erases what is on the left :-(

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA how to select from a point to the end

    ...but that's what I incorrectly posted and admitted just now.

    Have you tried Joseph's correction?

  8. #8
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: VBA how to select from a point to the end

    yes and its working :-)
    thanks richard and thanks joseph :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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