Help with Clear Contents

SUSAN BAXTER

New Member
Joined
Apr 1, 2019
Messages
47
<code class="western">[FONT=Liberation Serif, serif]I have one line in my code that deletes the data in the first cell to the right of a found search in a specified range. I would like to increase that ClearContents from 1 cell to 3 cells and I just can’t seem to find what that code is.[/FONT]</code>
<code class="western">
</code><code class="western">[FONT=Liberation Serif, serif]Cells(i, x).Offset(0, 1).ClearContents[/FONT]</code>
<style type="text/css">pre.cjk { font-family: "WenQuanYi Micro Hei Mono", monospace; }p { margin-bottom: 0.21cm; }code.cjk { font-family: "WenQuanYi Micro Hei Mono", monospace; }a:link { }</style>
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Works perfect!! Thank-you so much. <style type="text/css">pre.cjk { font-family: "WenQuanYi Micro Hei Mono", monospace; }p { margin-bottom: 0.21cm; }a:link { }</style>
 
Upvote 0
Try:
Code:
Range(Cells(i, x), Cells(i, x).Offset(0, 3)).ClearContents

This could also be written this way...

Cells(i, x).Resize(,4).ClearContents

Note: The resize is 4 (one more than the stated 3) because the starting cell is being cleared along with the 3 cells to the right of it)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top