jeff m
jeff m

Reputation: 275

How to clear a named range without using any VBA/Macros

I'm trying to figure out a way to insert a button or similar that when pressed, will clear all members of a named range.

Basically, how to replicate this:

Private Sub CommandButton1_Click()

    Range("Input_Cells").ClearContents

End Sub

What I want is to have a button, or some similar type of clickable/toggleable action, that when depressed would clear the contents of the Named Range. I could probably manage this with a listbox with something similar to below, but I'd rather have a prominent button.

=if(list_option = "clear", input_cells = "", )

Upvotes: 0

Views: 5970

Answers (1)

PowerUser
PowerUser

Reputation: 11801

Buttons don't do anything without code to control them. Even if you use a wizard to make the button, there's still code.

If you're trying to clear a form, then you're out of luck. However, if you just want to hide data from a results tab:

  1. Give the user instructions to enter "1" in cell A1 if they want to clear your result cells.

  2. Then in your result cells, use =if(A1<>"1","Some Result","")

This would have the effect of 'hiding' results at the user's discretion.

Upvotes: 2

Related Questions