Clearing Contents Of Cells

Apr 27, 2007

My computer runs on Excel 2003 but my Laptop is on Excel 2000, the problem is I have the below code on a spreadsheet I wrote on my Computer which runs fine but when I open it on my Laptop it comes up with a run time error it doesn’t like the clear contents line. If some one could explain to me why it is happening and how to get round the problem so it will work in Excel 2003 and 2000.

Private Sub Workbook_Open()
Application. ScreenUpdating = False
Sheets("data").Visible = xlVeryHidden
Sheets("Incidents").Visible = xlVeryHidden
Sheets("Front Sheet").Select
Application.ScreenUpdating = True
End Sub

View 2 Replies


Clearing Contents Of Specific Cells

Dec 7, 2009

I created a macro to clear cells but I can't get it to clear a number of ranges. It will only clear single ranges.

Sub DeleteStuff()
Dim c As Range
For Each c In Range("G6:G10", "H6:H10", "J6:J10")
If c "" Then c.ClearContents
Next c
End Sub

View 9 Replies View Related

Worksheet Change Event And Clearing Contents

Mar 28, 2007

I have the following code that 'sort of' works.

Private Sub Worksheet_Change(ByVal Target As Range) ...

View 9 Replies View Related

Clearing Cell Contents If Conditionally Formatted

May 3, 2009

This is my first use of the forum as I only joined yesterday after a recommendation from another colleague.

I am attempting to write a macro to clear the contents of cells in a range that have conditional formatting. Below is the formula I have used...

Sub clr()
Dim r As Range
For Each r In Range("09:050")
If InStr(r.Interior.ColorIndex, "40") Then r.ClearContents
Next r
End Sub

While the formula runs without error, it does not clear the contents, although I read on another thread on this forum that you cannot clear contents of cells that are conditionally formatted.

Alternatively, if there is a more efficient way to clear cell contents (without using a formula in the cell itself),

View 9 Replies View Related

Clearing Unprotected Cells

Jul 19, 2002

I have a spreadsheet that has I have protected. On this sheet I have a button labeled Reset Form. When you click the button it it goes to each Unprotected Cell and deltes the contents. I created this by starting the macro and then tabbing to each and every cell and deleteing the contents I then ended the macro...

Is there a code that I can use for to clear all unprotected cells as opposed to creating the macro manually?

View 9 Replies View Related

Clearing Cells Containing Specified Words

Apr 29, 2008

I am trying to clear the contents of cells in a very large spread sheet containing certain words. I am running the following macro and it will only do the first part, so it will clear cells containing "deceased" but stops at "esa". There may be any number of other words or text in the cell and I want it to delete cells with "esa" by itself so for ex. not delete cell containing "vanesa". I am very amateur so I am sure this is something simple but I cannot find the answer or figure it out for myself.

Sub DeleteAll()
Dim lCount As Long
Dim rFoundCell As Range
Dim rLookRange As Range
Set rFoundCell = Range("A1")
Set rLookRange = ActiveSheet.UsedRange
For lCount = 1 To WorksheetFunction. CountIf(rLookRange, "*deceased")
Set rFoundCell = rLookRange.Find(What:="deceased", After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

View 6 Replies View Related

How To Stop From Clearing Hidden Cells

Aug 10, 2014

I have cells, or columns hidden when I do not need them, but I have to a data entered in those cells to make my spread sheet work. Usually just 0.

When I do the all clear or " clear all contents" operation at the end of the day, it clears the hidden data/cells too. Is there anything I can do to stop excel from clearing those hidden cells?

View 3 Replies View Related

Clearing Merged, Multiple Cells

Mar 25, 2009

I have a macro where somone fills in a form and then it copies the data in the form to a database (another worksheet). Once the macro is run and has copied the form to the database, I then clear each cell seperately using the below code :-

View 5 Replies View Related

Clearing Selected Cells On A Form

Oct 15, 2013

I have compiled the following code with bits from here there and everywhere to clear the user entered details on a form. My problem is that I need to retain or reset to "Please Select" the cells with drop down lists.

In list form, I am trying to;

Unprotect the worksheet,
Select the cells with drop down lists and lock them,
Delete the contents of unlocked cells,
Selecting and unlocking the cells with the drop down lists ready for re-use,
Re-protect the worksheet.

(I probably should mention that my "Form" is just a formatted worksheet that looks like a form on the screen and when printed, not any sort of inbuilt Excel function that I have read about somewhere, probably here)

Sub ClearUnlockedCells()
' Clearform Macro
' Clear entered data from Form.
Dim WorkRange As Range
Dim DVRange As Range


View 4 Replies View Related

Clearing Cells Based On Condition

Oct 3, 2008

I've created (with the help of jmthompson from here) a macro to pull an entire row of data and copy to another sheet (Sheet1) if column U has "YES" in the cell.

Now I need to clear the contents of cells in range B-U after the copy has occurred.

Here's the current macro: ...

View 9 Replies View Related

Clearing Unlocked Cells On A Protected Worksheet

Dec 6, 2007

I have a workbook with a series of sheets that have tables for entering data. The table row and column labels and formulas in certain cells of each sheet are locked and some sheets are hidden.

When opening the file I want to clear all cell contents (interior color, comments, data, etc) in all the unlocked cells on each sheet that is not hidden.

I tried protecting the sheets first so only the unlocked cells would be accessible, but when I run the code below I get an error saying that the clear contents etc. cannot be performed because the sheet is protected. If it is not protected, everything gets wiped out.

How can I keep the locked stuff but clear the unlocked cells?

For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then

ws.Protect Password:="aaa" 'Protect each sheet
ws.Cells.ClearContents 'clear content of any unprotected cells
ws.Cells.ClearComments 'clear any cell comments
ws.Cells.Interior.ColorIndex = 0 'set background colour to no fill
Active.Cells.Range ("a1") 'make the active cell the top left

End If
Next ws

View 9 Replies View Related

Deleting / Clearing Multiple Cells In Target Range

Jun 2, 2014

I have a target range for a worksheet change. Then when finished I highlight the data and press 'delete' I get an error within the code.

View 2 Replies View Related

Combine Contents Of Two Cells Depending On Contents Of Another?

Jan 14, 2013

I am trying to combine the contents of two cells depending on the contents of another, I have tried to use the If function but am coming up stuck!

I have provided a link to the example file below:


View 4 Replies View Related

Having Cells Change Their Contents According To What The Contents Of Other Cells Are

Mar 25, 2008

I have a column in my .XLS whose contents I want to change depending on what the contents of the cells of a different column are. However, I only want two cells from the same row to be dependent on each other. So, for example, if $A$1 reads "1" then $B$1 should read "apple" and if $A$2 reads "1" then $B$2 should read "apple"; if $A$12 reads "3" then $B$12 should read "pavement" etc.

View 11 Replies View Related

Run A Macro Called "PriceForm" Instead Of Clearing The Cells

May 30, 2009

Code to run a macro called "PriceForm" instead of clearing the cells.

Private Sub Worksheet_Calculate()
Static MyMarket As Variant
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If [A1].Value = MyMarket Then
GoTo Xit
MyMarket = [A1].Value
Range("T5:X50").Value = ""
End If
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub

View 9 Replies View Related

Clearing Of The Cells Clears As Well The Copying Of "B30"

Oct 14, 2008

Sub test()


End Sub
Problem: the clearing of the cells clears as well the copying of "B30"

View 9 Replies View Related

Copying Merged Cells (3 Cells) Based On Contents Of Any Of 3 Cells To Right

May 29, 2014

I wish to copy a merged cell (3 cells) based on if only 1 of 3 cells to the right contain "X". if the top cell does not contain "X" than the merged cell is not copied. Also, is therea more elegant to copy 3 columns at a time rather than do one at a time as my code shows:

' CopyICUCAPU Macro
Dim i As Integer


View 14 Replies View Related

Show Contents Of Vertical Cells In Horizontal Cells

Nov 21, 2008

I am referring to the post made by NBVC at, Try: =IF($A1="",INDIRECT("A"&ROW()-ROW($A$2)+COLUMN(B1)),"") in B2, copied across and down

I have a similar case but there are no empty rows between lists, what would be the formula to get the same results? (The transposed address should appear next to each first line of each block).

Earlier, I posted at and I got brilliant answers, I also would like to get benefit of the above mentioned formula but in cases when there are no empty rows between lists.

View 4 Replies View Related

Clear Contents Of All Unlocked Cells (many Are Merged Cells

May 28, 2009

I am looking for a code that will clear all of my unlocked cell in sheet 1. That is not a problem but since many of the cells are merged I know it keeps throwing me an error saying cannot change contents of merged cells or something like that. Does anyone know how to get around this without unmerging the cells. I saw a code to unmerge all of the cells on a sheet but I really don't want to do this as I already have worked around most of my problems with the merged cells.

View 14 Replies View Related

VBA To Clear Contents Of Cells And Keep Some Cells Locked

Jan 25, 2010

I have written this code to clear the contents of certain cells, lock the content of others and protect the sheet again it works on sheet1 but not on sheet 7. This is suppose to happen when the Print button on my sheet is clicked.

View 4 Replies View Related

Add Cells Based On Contents Of Cells In Another Column

Feb 15, 2008

I have a spreadsheet that has columns stating both status and then further to the right in the row, currency totals. There are only two status options, Stocked and On Order. I need to add the total currency amounts based on this other column's listing and it must change if status changes.

(Put simpler:
Column A lists Stocked or On Order and Column B is the currency tied up in that row.
I need to make totals for the cells in column B based on the status listed in Column A and it must change when Column A is changed. This should result in two totals, one for Stock Status Currency and one for On Order Curreny)

View 5 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.


Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B4") = "Basic" Then ''*** B4 is adropdown ***''
'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

Moving Contents Of Cells?

Feb 9, 2013

About half of the time when I move the contents of a cell I get the message "The Clipboard cannot be emptied. Another program might be using the Clipboard"

View 14 Replies View Related

Delete Contents Of Cells With 0

May 15, 2009

Is there a way using a macro to check each row in Column D and Column F for "0", so that when both columns in the same row have "0" and only when both columns in the same row have "0" the contents "0" in that row of Column D and F will be deleted?

View 2 Replies View Related

Replacing Contents Of Cells?

Apr 11, 2003

I am doing a "text to columns" in a VBA script and each time it runs I get a "Do you wnat to replace contents of the destination cells" prompt. I will always say yes to this prompt. Is there something I can put into the code to avoid this prompt all together, again the answer will always be yes to the prompt.

View 3 Replies View Related

Copy Contents In 2 Cells - 1 Of Which Is A Date

May 7, 2014

In column A, i have cities.
In column B, i have dates.

I would like column D to have both the city and its corresponding date e.g. "paris (12/06/2013)"

However, I am getting "paris (41437)". Is there anyway to make the date appear properly?

View 3 Replies View Related

BOLD - Contents Of Cells In 2003

Nov 12, 2008

I cannot "BOLD" the contents of cells in my spreadsheet by clicking "B" on the menu bar. However I can do so by clicking on "Format - Cell - Font" and then using the selecting the Bold option. I wonder why this happens.

View 2 Replies View Related

Splitting Alphanumeric Contents In Cells

Jan 18, 2013

Cell A3: Abbott, Robert M.,MD
Cell A4: Bussiere, Laura P., ARNP
Cell A5: Bradford, Melinda ARNP

I have this data in Column A and I'd like each person's last name to appear in Column A and the first name to appear in Column B and the credentials to appear in Column C like this:

A3 B3 C3
Abbott Robert MD
A4 B4 C4
Bussiere Laura P. ARNP
A5 B5 C5
Bradford Melinda ARNP

Also I'd like to be able to do the same with addresses:

In Row Q I have:

Q35: Jacksonville, FL 33204
Q37: St Augustine, FL 32092-1850

I would like this to appear in the sheet as follows:

Q35 R35
Jacksonville 33204
Q37 R37
St Augustine 32092-1850

I don't need the state in any cell. It can disappear as well as any commas. Is any of this possible?

View 1 Replies View Related

Merging The Contents Of Two Cells In One Third Cell?

Sep 11, 2013

How can I let cell F5 for example contain both the texts or contents of cells A1 and B1? Is there a function that can do that purpose?

View 5 Replies View Related

Contents Of Cells Appear Based On Another Cell

Dec 14, 2013

I am working on a sheet where I want the contents of cells D1:D10 appear if cell A1 has a text in it and the contents of cells D1:D10 disappear if cell A1 is blank. What is the right conditional formatting formula for this.

View 3 Replies View Related

Copyrights 2005-15, All rights reserved