Clear Contents Of Named Range In 2007

Jan 4, 2009

I want to have users fill out. While it is possible to have it Read Only so that they always SaveAs I would rather put in a macro to clear the user input fields. I have done this in Excel 2003 and when I try using the same techniques in 2007 I get an Error 400.

I have all the cells (some are merged cells) in a named range and have the following code for clearing them.

View 3 Replies


ADVERTISEMENT

Clear Contents Of Cells In A Range, LEN=0

Dec 23, 2009

I'm using a macro to copy the results of a formula and paste the values only on another sheet. The result includes lots of "blank" rows. I have another macro to get rid of the empty rows and move the information up.

It's not working because the "blank" rows aren't empty. Even though I paste values only, experimentation shows that the cells that appear blank return a false to the ISBLANK test with a length of 0.

So now I think I need a macro to run after the pastespecial command to look for cells within a range with a length of zero and delete the contents of those cells, but leave alone anything with a length of >0.

I am brand new to the idea of using VBA, but I have successfully cobbled together some stuff and can usually modify things to work.

It seems I need to maybe use some sort of IF statement along with a LEN and ClearContents. I don't want to delete the blank cells, just make them truly empty so that all of my actual data stays where it should, and my delete empty rows macro works correctly.

I did a search and see some info on clearing contents of columns or rows, or clearing contents based on the content of other columns or rows, but I'm unsure of how to tell it to search each cell within a range and clear the contents of 0-length cells to make them truly empty.

View 10 Replies View Related

Clear Contents Based Upon Value In Row Range

Jul 21, 2006

I'm trying clear the contents of a column range when the cell above this column range is empty. I know how to do this for one cell, but I would like it to work for a rangefrom R15:BB15.

If IsEmpty(Range("r15")) Then
Range("r16:r35").Select
Selection.ClearContents
End If

End Sub

View 5 Replies View Related

Clear Contents Of Filtered Range

Jan 10, 2007

I am filtering column S in a sheet to show all rows with a date after the end of the previous month - i.e. >= 01/01/07. What i want to do is clear the contents of those visible cells in column S. I tried the code below (got it on this site) but it works its way up from the bottom of the sheet until it finds the first visible row and then clears the contents of column S in each row above it, whether it is visible or not.

Sheets("Planning").Select
With Range("e2:C2")
.AutoFilter field:=5, Criteria1:="<=" & Sheets("Filtered Statistics").Range("c3")
.AutoFilter field:=19, Criteria1:=">=" & Sheets("Filtered Statistics").Range("d3")
For i = Range("s65536").End(xlUp).Row To 3 Step -1
If InStr(1, ">=" & Sheets("Filtered Statistics").Range("d3"), Cells(i, 19).Value) = 0 Then
Cells(i, 19).ClearContents
End If
Next i
.AutoFilter field:=19
End With

View 2 Replies View Related

Clear Named Range & Columns To Right

Sep 17, 2007

I have a dynamically named range the contents of which I want to clear. However, I also want to clear the cell contents in the next column beside the range. So if my dynamically named range is A20:B40 can I clear the contents of A20:C40 without changing the initially named range. Background: The data I have is the result of an advanced filter. The range is named for printing purposes without the final column.
If I then change one of the raw data I want to run the filter again. To do this I need to clear the first filter.

Range("AIT_Change_Management").ClearContents

View 7 Replies View Related

Clear Contents Of Column In Range Variable?

Feb 11, 2014

I have a range variable named data I want to clear all the data in the 3rd column in the range variable I know how to reference a single location in the range variable but not a whole column. see example code below

[Code] .....

View 3 Replies View Related

Automatically Clear Contents Of Cell Range

Jan 17, 2013

Is is possible to clear the contents of a cell range if a message box appears stating an error. I have tried the following code but the logic doesn't actually work and am struggling to achieve what I am trying to do.

My code so far is as follows:

Code:

If ActiveSheet.Range("F84") > 0 And ThisWorkbook.Worksheets("PES").Range("D24") = 0 Then _
MsgBox "Your Entitlement is currently 0", vbCritical, "Error"
ActiveSheet.Range("K84:T84").ClearContents

The message box appears fine if the IF statement is true but if IF statement is false, the cell range of K84 to T84 on the current sheet is still cleared..

View 2 Replies View Related

Clear Contents Of Range Based Upon Values

Dec 17, 2007

There is data(numerical) or blanks in each of the cells in the range H32:O37

I want to clear the contents if they are a duplicate of the previous line.

Looking for a macro hopefully. Found many to delete the whole row but just the specific range based upon the duplicate criteria..As there is data surronding that area do not want to delete whole row just clear that specifc area.

H32:O32 clear contents if same as H31:O31 if any valuse are different then stays the same
H33:O33 clear contents if same as H32:O32 if any valuse are different then stays the same
H34:O34 clear contents if same as H33:O33 if any valuse are different then stays the same
H35:O35 clear contents if same as H34:O34 if any valuse are different then stays the same
H36:O36 clear contents if same as H35:O35 if any valuse are different then stays the same
H37:O37 clear contents if same as H36:O36 if any valuse are different then stays the same

View 9 Replies View Related

Clear The Contents Of Each Cell In A Range Without Losing Formulas

Dec 6, 2006

Is there a way to clear the contents of each cell in a range without losing formulas?

View 9 Replies View Related

Excel 2010 :: Clear Contents Of A Range Of Contiguous Cells

Jun 4, 2013

I am trying to clear the contents of a range of contiguous cells (containing formula) in Excel 2010 64bit. But it is taking a LONG time (read >30min to clear a range 288 x 100). Originally was doing it in VBA but it was taking too long so I started stepping through the macro and identified that the slow down was occurring on a particular sheet only. So the problem is in Excel....not VBA because it is still very slow when deleting the same range in Excel without using VBA.

I've tried all the usual suspects including: Application.EnableEvents = False (run from the VBA Immediate window when using Excel without VBA), Setting to Example of slow clear contents5.xlsxExample of slow clear contents5.xlsxManual Calculation, Turning off screen updating, deleting all the conditional formatting on the sheet, removing any data validation from the sheet (yes all these at the same time). There are no links to external workbooks. I've even tried in VBA changing from .ClearContents to .Value = vbNullString. All to NO AVAIL! By way of background the file is about 72Mb #.xlsm.

If I try to clear contents of larger ranges on other sheets in the same workbook it is instantaneous. If I copy the problem worksheet off to a new workbook, I can delete the problem range almost instantly. Why deleting a range of cells should take so long! Again to clarify, I am using the terms "delete" and "clear contents" interchangeably, but they both mean "clear contents" (not delete and move up cells). P.S I've also looked into the reported conflict between Excel and Google Desktop Office Add-in (Office Button->Excel Options->Addins->Com Addins and deselect Google Desktop Office Addin) but I didn't have Google Desktop Office Add-in so it isn't that.

View 6 Replies View Related

On Cell Selection, In Named Range, Clear Content Or Add Text If Empty

Jul 24, 2009

I wrote some code that toggles bewtweeen the word "Yes" and the function clearcontents.

What it does not do, is if you click on cell A1 and change it's contents and you click on the same cell again it does nothing. You need to click on another cell say A2 before you can go and change A1 again.

My code is as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub

If Not Intersect(Target, Range("Documents")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Value = "Yes"
Else
Target.ClearContents
End If
Application.EnableEvents = True
On Error Goto 0
End If

End Sub

View 3 Replies View Related

Combine Cell Contents With Named Range?

Aug 8, 2013

I have a cell with a drop-down menu where the user can select "Plant A" or "Plant B".

I have a cell below that with a sales number, which comes from a different tab where the sales number is input and has a named range.

For example, the input tab has a named range called "Plant A Sales" and a value of 1234, and a named range called "Plant B Sales" with a value of 5678.

I want to put a formula in a cell that will look at the cell where the drop-down menu is and will populate that cell with the correct data for the selected plant.

So if the user selects "Plant A" from the drop-down menu, the cell will show "1234". If they then select "Plant B" from the drop-down menu, the cell will show "5678".

View 1 Replies View Related

Display Contents Of Named Range On Userform

Oct 18, 2007

i have a userform with a text box in it a i would like to display all the values in a named range called "emp1"

View 4 Replies View Related

Display Named Range Contents Based On Text In Cell

Aug 24, 2009

I have some dynamic named ranges in sheet1, and in sheet2 I have data validation dropdown list which has the names of all the DNR's in it.

What I want it to do (in sheet3, no less) is for the user to be able to pick a named range from the dropdown list, and have a particular column in sheet3 then display that entire named range.

I have made a 'data' worksheet which is the source for the data validation in sheet2. Each item in the list identically matches the name of each of the named ranges. I was hoping to be able to use some form of =INDIRECT but alas, no such luck.

So it's almost like a copy and paste function I'm after, where:

If you pick "Schedule_From" out of the DD-list, then DNR 'Schedule_From' is what is pasted in Column B in Sheet3.

DON'T want to use a PivotTable.

View 9 Replies View Related

Excel 2007 :: Crashing Using Named Range In Conditional Formatting?

Feb 10, 2014

I have one simple (but large table). It has dates across the top (formatted in hh format). I would like the associated table to format according to the day and also to format differently when there is a public holiday. So I have built a table with the holidays and named the relevant cells as "Holiday_Valid".

I have the following formula in the conditional formatting;

[Code]....

Where D11 has the current day in question and Holiday_Valid is a list of public holidays. Since there is a cell for each hour of each day I am using "int()".

There is a second conditional format to format Sundays differently as below;

[Code] .....

My problem is that these both work well....but then after a few minutes the whole sheet crashes with those dreaded "Trying to recover your data" and "Excel will restart" etc.

I have removed references to named ranges and so far - so good....but this means putting the validation table in the same sheet as the main table. In the past I have been able to use named ranges (albeit not in such convoluted formulae), but now it seems that it is not working any longer.

When I open the recovered sheet, all the conditional formatting has been removed and the message from the repairs is that there was some invalid conditional formatting.

Extensive web searches did show some issues with conditional formatting using names ranges....especially with frozen panes....which I need use with a sheet this big.

View 4 Replies View Related

Clear Old Data And Add New Data Every Month, The Named Range Changes

Dec 13, 2008

I have 30 worksheets in a workbook in which the first sheet is called summary. The summary sheet has 29 formulas with all named ranges, so one named ranged per worksheet. The issue I have is when i clear old data and add new data every month, the named range changes on some worksheets not pointing to the correct range as previous month file even if I have $

View 9 Replies View Related

Excel 2007 :: Applying Conditional Formatting To A Dynamic Named Range?

Jul 10, 2012

I have an Excel 2007 Workbook which is refreshed by a Web Query. I have dynamic named range defined as "Manager" which I've confirmed is correctly identified. This range includes only one column and is formatted as text.

When I try to reference this range in my conditional formatting "refers to" formula, all cells are recognized as blank even though the range clearly contains many cells that are not. For example, there are 90 records containing the initials "PD". If I use the formula =Manager="PD" in my conditional formatting, nothing changes. If I change it to =Manager="" then ALL records are formatted, including those that are not blank.

Stranger still, if I enter the formula =COUNTIF(Manager,"PD") into and empty cell in my worksheet those 90 records are counted correctly. Which leads me to believe it isn't about the data. Conversely, =COUNTIF(Manager,"") returns the correct count of only cells that are, in fact, blank.

I've tried using the OFFSET formula defining my range in place of the name itself for my conditional format formula to no avail.

View 2 Replies View Related

VBA Clear Contents

Feb 5, 2010

i am trying to use clearcontents with the below code but i get an error,


With Sheets(1)
With .Range("J7")
.ClearContents Range("J7:J" & .Range("A" & .Rows.Count).End(xlUp).Row)
.Formula = "=H7-I7"
.AutoFill Range("J7:J" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With
End With

View 9 Replies View Related

Clear Contents Of Cells

Sep 10, 2013

I want the function of clear contents to work based on the value of B4. If I run the code with clear content part excel crushes.

VB:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B4") = "Basic" Then ''*** B4 is adropdown ***''
ActiveSheet.Unprotect
'Range("B10,F10,H10").ClearContents ''*** if I run this part the excel crushes ***'''
Range("B10,F10,H10").Locked = True

[Code] .....

View 4 Replies View Related

Clear Contents If 2 Characters Or Less

Feb 10, 2010

I am looking for a way to remove text from a cell if it is 2 characters or less but do nothing if the text is longer than that. Is there a way to do this with either a function or an advanced find?

For more detail, I have a list of middle initials and last names. The cells are either a middle initial by itself like "D." or they are a last name like Jones. I want to go through and delete the cells that have the middle initial and leave the ones with the last name. So if there is a function that will evaluate the cell, and if it is 2 characters or less, then delete the contents. If greater than 3, leave it alone.

View 3 Replies View Related

VB Code To Clear Contents

Jul 3, 2014

I have a range of cell content to be clear (Value only) but no formula in those cell.

The range is populated in cell H106.
Example cell
if cell H106 = D5:E102 then clear the value value only in cell range D5:E102
if cell C106 = G5:H102 then clear the value value only in cell range G5:H102.

View 8 Replies View Related

VBA To Clear Contents At Specified Intervals

Mar 6, 2014

I think I've had enough of using excel generated macro's as an excuse for decent code. I need to turn this:

Small procedure, function, what have you that will continue this pattern until I hit some kind of indicator to tell it to stop. This just clears the contents from 7 rows, hops down 9 rows and does it again.

View 14 Replies View Related

Clear Contents In Various Worksheets At Once?

Dec 2, 2011

I have a monthy activity where I would like to clear the area B13:P42 on various worksheets in the same spreadsheet. Is there an easier way to do this rather than just recording a macro?

View 5 Replies View Related

How To Clear Cell Contents

Jan 17, 2012

I have the following code where I want to clear the cells.

Code:

Workbooks(strOutputFileName).Sheets(2).Activate
Range("F9:F25,C27:E57,F59:F60,J9:J25,G27:I57,J59:J60,N9:N25,K27:M57,N59:N60,R9:R25,O27:Q57,R59:R60").Select
Selection.ClearContents

When I run this code, where it should select G27:I57, it instead selects G27:N57!!!!

When I manually try to select the G27:I57, the selection jumps to the right to N57.

When I use this piece of code on a different worksheet, it works OK!

View 6 Replies View Related

Clear Contents Of Entire Row?

Jan 21, 2012

Macro to clear contents of entire row if any cell in Range A2:A17 is Empty.

View 9 Replies View Related

Clear Contents Of Dropdown Box?

Feb 27, 2012

I am trying to have a macro clear out the contents of a cell before it quits, the cell contains validation data in the form of a list. My goal is to force the user to choose an option every time before exporting a file, the cell contains what will become a part of the filename. I want to make sure the user, usually me, remembers to change it each time rather than accidentally saving over another filename. I had the following code and kept getting a 400 error (nice and specific)

Code:
ActiveSheet.Range("O3").ClearContents

The only way my macro will run without a 400 error is if that line is commented out. Is there any way to clear out the cell and retain the validation data dropdown list?

View 1 Replies View Related

VBA To Clear Contents But Not Header?

Jul 30, 2014

i have a vba that clears content from specific cells, hence somehow it also deletes the header as well

This is my code:

Dim LastRow As Long
Sheets("All").Select
LastRow = Range("J" & Rows.Count).End(xlUp).Row
Range("A2:J" & LastRow).ClearContents
Sheets("All").Select
LastRow = Range("AO" & Rows.Count).End(xlUp).Row
Range("AI2:AO" & LastRow).ClearContents

View 9 Replies View Related

Macro To Clear Contents.

Aug 20, 2008

I'm trying to figure out code to have only the contents of cell 'a2' cleared when the contents of cell 'a1' is changed. The issue is that both cells are derived from lists and I don't want the formats cleared.

View 9 Replies View Related

Vba Clear Contents Of Column

Apr 8, 2009

I dont know how to copy an excel sheet into the question.

But assuming the following text starts at CELL C2 (this is just a section of the workbook)

C D E F G

1x55Correct!
2x55Try Again?
3x55Try Again?
4x55Try Again?
5x55Try Again?

This is a worksheet to test multiplication tables. I am trying to create a macro button to clear the contents of column F, for the kids to start again?

View 9 Replies View Related

Macro For Min Value Then Clear Contents

Sep 30, 2009

I need code for a macro that will find a min value in a particular column and based on that min value clear the contents of other cells for that min value.

For example, I have dates in column E such as:

200907
200906
200902
200809
200803
200710
200707

Therefore, I need to find all records for 200707 and clear the contents in other cells.

I can't hardcode the min date because that can change from month to month when new files are created. As can the number of rows.

I'm using Excel 2007.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved