Consulting

Results 1 to 2 of 2

Thread: ClearContents (Differnt columns)

  1. #1

    ClearContents (Differnt columns)

    I have this code that clears the contents in the first 28 columns in the active row. How can I include columns 95 to 107 (ignoring 29 - 94)

    [VBA]ActiveCell.Resize(, 28).ClearContents[/VBA]

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,042
    Quote Originally Posted by av8tordude
    I have this code that clears the contents in the first 28 columns in the active row.
    Not quite; it will only do this if the active cell is in column A, if the active cell is in any other column, the cells cleared will be the active cells and the 27 cells to the right of it.
    It might be safer to have:
    [VBA]cells(activecell.row,"A").resize(,28).clearcontents[/VBA]
    Quote Originally Posted by av8tordude
    How can I include columns 95 to 107 (ignoring 29 - 94)
    Perhaps by adding a second line:
    [VBA]cells(activecell.row,"A").offset(,94).resize(,13).clearcontents[/VBA]
    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.

Posting Permissions

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