Consulting

Results 1 to 3 of 3

Thread: Clear contents with in a range in Excel through VB

  1. #1
    VBAX Regular
    Joined
    Jul 2018
    Posts
    7
    Location

    Clear contents with in a range in Excel through VB

    Hi,
    I am trying to clear contents for column A to D.
    I used below statement which worked.


    Sheet1.Range("A").ClearContents

    Now, I have a scenario where in I should not delete value in cell A1.
    My range is from A2 till Col A end and Cols B,C and D.
    Can anyone suggest how can we get this range cleared
    Thanks in advance

  2. #2
    Knowledge Base Approver VBAX Guru
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    4,111
    lr = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
    If lr > 1 Then Sheet1.Range("A2:D" & lr).ClearContents
    p45cal - - - - -This is my signature, it appears after all my posts. Below is not directed at anyone in particular - so don't take offence! - (You might guess why it's there though)
    If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Jul 2018
    Posts
    7
    Location
    Thank you.This solved my issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •