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
    12
    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 Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    lr = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
    If lr > 1 Then Sheet1.Range("A2:D" & lr).ClearContents
    p45cal
    Everyone: 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
    12
    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
  •