Clear Contents Macro Help

liquidmettle

New Member
Joined
May 23, 2013
Messages
48
Hi All,

I'm fairly sure this will be an easy one, just can't figure out where I've gone wrong.

I have a sheet named "Update" that I want to put a button on to erase a range (just the contents) on a sheet called "Action Plan".

I do not want to make Action Plan the activesheet, I just want the button to erase it from the Update sheet.

I am trying to use this macro code, but its telling me there is an error:

Sub quarter1()
Sheets("Action Plan").Range("G18:g166").ClearContents
End Sub

Something I'm doing wrong?

Thanks in advance!

-LM
 
Rick,

I am not certain how I would combine your code into the code already designed to make sure the sheet references are correct.
Sorry, I should have included that for you (I colored the addition in blue so you can see what I changed)...
Code:
Sub ClearCellsSomeOfWhichAreMerged()
  Dim Index As Long, Cell As Range
  Index = 18
  Do While Index <= 166
    Set Cell = [COLOR=#0000FF][B]Sheets("Action Plan").[/B][/COLOR]Cells(Index, "G")
    If Cell.MergeCells Then
      Cell.MergeArea.ClearContents
      Index = Index + Cell.Rows.Count
    Else
      Cell.ClearContents
      Index = Index + 1
    End If
  Loop
End Sub
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Jon, I retried that code and it does indeed work for me now too. I re-assigned the macro to the button before I hit it this time. I'm to go ahead and assume it was still trying to run some errant version of the code (I didn't think to re-assign it as I assumed it would run the new code under the same macro name).

Either way I want to thank you tremendously for sticking with it!

Thank you as well Rick even though I did not use your code.

Both of you Rock for being willing and to help and following through.
 
Upvote 0
I think you might have still used the code from Post #6 (before expanding it to 3 columns)


anyway, glad to hlep, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,838
Members
449,471
Latest member
lachbee

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