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


ADVERTISEMENT

Cell To Clear Contents Of Group Of Locked Cells?

Feb 22, 2013

I have created a worksheet with many calculations based on user input into several unlocked cells. I would like to create a cell that when selected, would clear the contents of this group of unlocked cells.

View 10 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

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

Conditional Clear Contents Of Cells

Oct 10, 2008

I have a dropdown list in the range E17:E91 containing a list, and two of the values in the list are "DI" and "LTC". What I need to happen is if either of these are selected, the corresponding cell in column F needs to have it's contents cleared. Ex. if in E17 the value is ever either DI or LTC, cell F17 gets contents cleared. if column E contains ANYTHING ELSE, nothing happens. That's all, I've taken care of conditional formatting and data validation already. So even if data is pasted in the worksheet into column E it needs to recognize that and always act in real time.

View 14 Replies View Related

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 Repeated Cells Contents

May 18, 2007

how could i clear repeated cells contents of one column with code suposing that there are some blank cells between the first empty cell and the last?

View 8 Replies View Related

Clear The Contents Of All The Cells In A Certain Area Of The Worksheet

Dec 8, 2008

I’m working on a macro to clear the contents of all the cells in a certain area of the worksheet that are not locked and do not contain a hyperlink.

(C7 is the first data-entry cell; EndPage1 is a specific cell near the bottom right of the sheet that sets the outside range of the cells to be cleared. This is the code so far:

View 2 Replies View Related

Clear Contents & Change Color Of Cells

Nov 3, 2006

how to clear contents and change colour index of cells.

This is for a booking system. The current VB codes allows bookings to be made by entering a reference number, dates of bookings and room type and bed type. When the VB codes are executed, the cells corresponding to the details entered earlier, would fill the booking table with the reference number and change the colour fill (e.g. yellow) to indicate that the slots are booked. Please refer to attached sample.

However, I do not know how to delete the booking. I would like to assign a cell for user to enter the reference number that needs to be deleted. So when the reference number is entered into that cell, user could execute a function which will clear the contents and change the colour index to none for that particular booking with that reference number(s).

Attached is a sample of the problem.

View 9 Replies View Related

Clear Contents In Specific Cell And Cells In Next 2 Columns To Right?

Jul 3, 2014

I am currently using this Code to search column1 for a Key Word that is entered into textbox "Kunde" on my userform.

[Code] .....

What i would really like to be Abel to do is :

Search for the cell in column1 with =Kunde.Value

Clearcontents of this cell and the 2 adjacent to the right.

i.e. Word is found in A7

Cells A7:C7 contents are cleared and fill Color returned to default colorindex 0

View 3 Replies View Related

Macro To Clear Contents Of Cells When One Cell Equals To 0 %

Oct 8, 2013

I'm trying to create macro that will clear the contents of the cells in the 4 columns to the left of a cell that = 0 %, as well as the cell that = 0%. For example, if cell F13 = 0 % then the contents of B13:F13 would need to be cleared. The range in which data is being pasted into is B13:F27.

View 4 Replies View Related

Protecting Formulas In Cells From Clear Contents Command

Sep 19, 2007

I have a worksheet from which I regularly clear all contents by selecting all the rows and selecting 'Clear Contents' from the right button menu. However, I now have added a formula in Col Y that I want to protect. I know I could select all columns up thru X, but that would clear the R1 headers, so I want to avoid doing that. I can always work around, but I'm curious, is there a way to clear only values and thus protect the formulas when using the Clear Contents command?

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

Clear Contents Of Cells Based On Data Validation Selection

Apr 13, 2012

I am trying to find something that would allow me to have a spreadsheet clear the contents of a certain cell based on the selection made from a data validation list which resides on the same row. This can best be described with an example.

The user selects anything but " " or "none" from the validation list, which for this example resides in C5, would trigger code to clear the contents, if any, in AA5. If " " or "none" is chosen the value remains.

This capability should be available for each row through 100.

View 3 Replies View Related

Retain Formulas In A Few Cells In A One Worksheet So They Are Not Cleared By "clear Contents" Without Using Protect Sheet

Apr 8, 2008

i have a worksheet which is a form which feeds into another worksheet which acts as a database. i have a button which clears the form based on code which is essentially "clear contents".

the problem is i have a few cells where i would like to retain the formulas. i tried to do this with custom in validation but this did not work. i also tried to enter the code directly into the worksheet but this didnt work either (my skills are limited..). i am avoiding using protect sheet bc that in turn will affect many of my other buttons. is there something i am overlooking?

View 9 Replies View Related

How To Copy Row With Formula In Locked Cells And Insert Copied Cells In Protected Sheet

Mar 29, 2014

Have you ever copy a row with formula in locked cells & insert it in a protected worksheet?

View 1 Replies View Related

Protect Certain Locked Cells From Editing And Allow Certain Unlocked Cells To Be Changed On Multiple Worksheets?

Jan 31, 2014

1.I need to protect certain locked cells from editing and allow certain unlocked cells to be changed on multiple worksheets.

2.When all of the changes are made to the unlocked cells, I need to password protect the entire workbook (except one worksheet) from any changes. (i.e. Prevent even the unlocked cells from being edited)

3.I also need a password to un-protect the workbook and return it to the state described in # 1. above .

View 1 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:

Sub CopyICUCAPU()
'
' CopyICUCAPU Macro
'
Dim i As Integer

[Code].....

View 14 Replies View Related

Macro To Clear Certain Cells In Row If First Cells Date Is In The Past

Apr 9, 2014

I would like to run a macro that would check if the date in the first cell of row is in the past.

If yes, then it would clear contents of cell in B,C,F,I,L of the same row (PLAN + SHIFTS). Or even better it would set them to 0 (zero).

Then it would hide the entire row. Is this even possible?

Please see the example: Excel.JPG

View 8 Replies View Related

Macro To Clear Cells With Numbers But Not Cells With Formulas

Jan 22, 2013

Macro to clear cells with numbers but no cells with formulas with in this macro:

Dim i As Long
i = Range("E3")
If i > 0 Then
' Copy range
Range(Cells(6, 10 + i), Cells(500, 17)).Copy
Range(Cells(6, 10), Cells(500, 17)).Select
' Paste special
ActiveSheet.PasteSpecial Format:=2, Link:=1, _
DisplayAsIcon:=False, IconFileName:=False
' Clear i columns on the right
Range(Cells(6, 18 - i), Cells(500, 17)).ClearContents
End If
End Sub

The range is where the cells with numbers need to be cleared but not the ones with formulas.

View 2 Replies View Related

Jumping Locked Cells

Oct 21, 2008

kindly help in jumping locked cell in a proteced worksheet..

View 9 Replies View Related

Check Locked Cells

Nov 6, 2008

Sub PastSpec()
If Selection.Locked = True Then Exit Sub
On Error GoTo ErrHan
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ErrHan:
Exit Sub
End Sub
I recorded part of it and adapted it afterwards. You will notice I have a line to check for locked cells, this does its job if the cell selected is locked. However if the cell selected is unlocked and the cell below is locked the code still excutes and pastes.

View 9 Replies View Related

Clear Cells In Column Where 2 Cells In Same Row Are Filled

Mar 30, 2008

how do i create a formula or macro that will: Clear the contents of Cell C1 If Both Cell A1 And B1 Are Filled. I will need to check all the cells in column A,B and C.

View 2 Replies View Related

Can't Click Hyperlink In Locked Cells

Jun 10, 2013

Any way to make it so that a cell can remain locked but be able to click a hyperlink? I need the cell to remained locked so nobody can alter the hyperlink name and value but I would like users to be able to click it and have it open in their browser.

View 9 Replies View Related

Locked Cells Have Changed Formatting

Jan 23, 2014

On an excel document that was originally formatted as a number and then locked, somehow users have changed the formatting to a date. I think it is an accident, but I can't figure out how they are doing it. I have several data files on a server where several offices have access to them to input data and somehow formatting gets changed sometimes, even when locked.

View 3 Replies View Related

Macro Is Unlocking Locked Cells

May 7, 2008

I'm using three different workbooks for the macro I've designed. The macro works exactly as I planned it would, but I'm getting a curious side-effect of running the macro. I have over 5,000 workbooks that I need to open, unprotect, change (mostly by copy/paste), and reprotect. It's a fairly straight forward macro, but it is my first, and I must be overlooking something. When the macro is complete, cells that were not modified via the macro in any planned/anticipated way are being unlocked. This has left me puzzled and frustrated. The files are opened, unprotected, the cells are copied over as planned, reprotected, and closed/saved. Everything works perfectly, but the cells in parts of the workbook (Filename) (which were locked before the macro ran) have been unlocked and are no longer protected when the workbook is reprotected. Again, these cells were not within the ranges modified, and I'd rather not have to format every cell in every one of the 5 sheets of (Filename) to be locked.

File names are:
"Finished Goods Inventory TREE (ToDMSI).xls" (alias: Workfile - sheet providing file path to be updated)
"Random_workbook_selected_from_previous_filename.xls" (alias: FileName - the copy-to file being updated)
"MACRO TEST BOM Master.xls" (the copy-from file always open)

Comma Delimited table layout in "Finished Goods Inventory TREE (ToDMSI).xls":
Col A, Col B, Col C, Col D
Customer ID,Item Code,File Name, Directory
4FRE01,4FRE01-0001,4FRE01-0001.xls,4FRONT

Here's the

Public FileName

Public Workfile

Public ItemCode

Public CustCode

Sub OpenBOMSeq()

View 14 Replies View Related

Locked Cells With VBA And Ability To Filter

Oct 23, 2008

how to create two buttons so that I can have a data entry specific protection and then a lock all button. Here's the link to the thread:

http://www.excelforum.com/excel-prog...-a-button.html

And here's the code I'm currently using:

View 3 Replies View Related

Select Locked Cells In 2000

Jun 15, 2009

I've created quite a few workbook/worksheets in excel 2007 compatibility mode that are data entry intensive. When protecting these worksheets, you have the option of allowing the user to "select locked cells". I invariably uncheck this option because the user doesn't need to interact with these cells.

However, several of my users are running Excel 2000 and the same option is not available when one protects a worksheet in Excel 2000. Is there a way to do that in VBA for these Excel 2000 users such that when they click on a locked cell, the cursor will not respond to that cell?

View 5 Replies View Related

Edit Locked Formula Cells

Aug 12, 2006

I have a template that I have hidden the formulas but allowed editing. Is it possible to create a pop up box for the end user to use to edit a cell with the hidden formula? This is a budget template with already set up formulas but the end user needs to be able to make edits but the end users are beginner excel users and if they double click on the cell the formula will automatically delete leaving the cell blank. I need a way around this so they cant view the formula but only change the data if they really mean to change it.

View 3 Replies View Related

Identify Locked Cells On Worksheet

Oct 19, 2006

Is there an easy way to show/return any Unprotected Cells on a Protected Worksheet?

View 8 Replies View Related







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