How To Clear Contents / Delete Rows On Click Of Button

Nov 3, 2013

I have a spreadsheet containing 100 "requests" which can be made by a user

i would like the option for the user to be able to delete a request should they wish it either by deleting a row or clearing the contents

Currently I have a single column which is full of buttons (one for each row)

when i click the button on row 10 I would like row 10 deleted

when i click the button on row 30 i would like row 30 to be deleted etc

is there a way to do this without writing 100 macros which are specific to each line?

View 4 Replies


ADVERTISEMENT

Clear Contents Vs Delete

Apr 24, 2007

I've been pressing on with my project and figured out that I really do not know the difference between Deleting and Clear contents. I really thought they were the same but am now unsure. I guess I have 2 questions. Which is better to use? what I'm doing is removing old data and importing new data. and which is more efficient for writing code.

Sheets("Bodies"). Range("A2:Z65000").ClearContents

Sheets("bodies").Range("a2:Z65000").Delete

View 6 Replies View Related

Command Button Click Creates New Rows Above Button?

Nov 8, 2012

I currently am using a form button to create new rows.

I need two different kind of buttons. I have a button that does this-

VB:
Sub InsertRow()
'this inserts a row where the button is clicked.
Dim r As Range

[Code]....

However, when I try and create these codes using a Command button (I need it for the color), I get the error

"unable to get the buttons property of the Worksheet class"

P.S one other thing, say the button is in row 3, and Cells A1 and A2 are merged, when you click the button in row 3, it should extend the merge to A3.

View 4 Replies View Related

Code To Clear Cell Contents For Rows?

Sep 12, 2012

Small piece of code to clear the contents of

Rows 33 thru 100 , then
Rows 142 thru 209 , then
Rows 251 thru 318 , then upto
Rows 43524 thru 43591 then finish

View 5 Replies View Related

Clear Contents Of Rows To Reset Used Row Count?

Jul 18, 2013

I am working on some code that I would like the user to be able to re-run should the underlying data in the adjacent tabs change. My existing code is shown below

Code:
Option Explicit
Dim wb As Workbook
Dim ws As Worksheet

[Code]....

I'd like to be able to remove all data on the ALL tab so that when the UsedRange.Rows.Count is run again on that page it will only see the header row. In the past I've deleted or cleared data from the sheet and the Rows.Count still counts the rows which have no content in them.

View 2 Replies View Related

Macro To Attach To A Button So I Can Delete The Contents Of All VALUE! Cells

Nov 26, 2008

how i might create a macro to attach to a button so i can delete the contents of all VALUE! cells. Either this or have a script in the background so no cell will return VALUE! (or any other error if possible)

I know if i had all the formulae sorted they might not butit's quite a large spreadsheet. The reason for the VALUE! error is text in cells that the formal points.

View 2 Replies View Related

Macro Button Click - Show / Hide Set Of Grouped Rows

Nov 12, 2013

I found this code for a button, so I can collapse and expand a set number of rows within that sheet. It works exactly the way i want it to, however, now I have a second sheet in my workbook, and I used the same button. Problem here is that when I activate the button, it opens the same rows in EVERY sheet in the workbook. "For each ws in Worksheets" so my question is what is the term for it to only work on a certain worksheet?

Code:
Private Sub ToggleButton1_Change()Application.ScreenUpdating = False
Dim ws As Worksheet
With ToggleButton1
If ToggleButton1.Value = True Then
For Each ws In Worksheets

[Code] ........

Other questions is about the ability to send an MS Outlook email from inside of excel.

I've been trying to find something that does the following:

Click button, Form pops up, has drop downs to select recipient, has field for subject, has field for message body, sends email.

View 2 Replies View Related

Click The Master Button, That Would Click Another Button On A Different Worksheet

Oct 22, 2008

Running into this issue of "transworksheet macros"

I have a master "update" commandbutton on sheet 1. I have two sub "update" buttons on sheet 2 and 3 respectively.

What I would like to do is have the user click the master button, that would "click" the two sub buttons so they run their respective macros on their respective worksheets (within the same worksheet.

I have tried pasting the macro code in the master button, telling it to select the sub worksheet and then run the macro, but the marco runs itself on the master worksheet instead.

View 6 Replies View Related

Delete Rows Missing Contents In AF Then A

Jul 23, 2009

If a row in Column AF does not say “Cust” than I want to delete it, next if a row in Column A does not say “Numb” I want to delete it.

View 3 Replies View Related

Delete Contents From Multiple Rows

Dec 29, 2012

I'm trying to put together functionality which allows the user to remove cell content within a selected row. I've chosen to remove the cell content rather than to delete the whole row because I need to maintain the 'Input Range'.

The code below is the script which I've put together to clear the cell contents.

Code:
Sub DelRow()
Dim msg
Sheets("Input").Protect "password", UserInterFaceOnly:=True
Application.EnableCancelKey = xlDisabled
Application.EnableEvents = False
msg = MsgBox("Are you sure you want to delete this row?", vbYesNo)

[Code] ........

The code works fine if the user selects one row. However, if the user selects mutliple rows, although the text values are removed from all rows, only the 'Interior Color' is removed from the first rather than all and I'm not sure why.

View 3 Replies View Related

Move Cell Contents & Delete Rows

May 23, 2006

I have a spreadsheet with a serial number is row 1 in column A with the rest of Row 1 empty. Column A is empty in Row 2, but has the data associated with the row above in columns B through L of Row 2. Then comes 2 blank rows and the pattern repeats with a new serial number in column A of row 5 and so on. I would like to move the serial number down one row, delete the now empty first row, delete the following 2 empty rows, and then loop to do the same thing again for all 9000 rows of the spreadsheet.

View 2 Replies View Related

Delete Rows Based On Cell Contents

Aug 29, 2007

I have merged two workbooks into one. What I need to do at this point is to delete all rows that have a duplicate entry, basically anytime the cell content in one cell matches the cell content in the cell right below or above it, BOTH rows should be deleted. At this point, this is above my VBA skills so I'm asking for help in how to do this. The stripped version of the workbook is attached (only 100 rows) but in reality this is a huge workbook with almost 22,000 rows.

You will notice in the attached workbook, that cell contents for A2 and A3 match. For what I need to do, I need both rows (2 and 3) to be deleted. If you go down a bit, starting in row 89 all the contents in column A are unique so those need to remain.

View 3 Replies View Related

Click On Color Button And After Button Click It Will Color Entire Row Of Cell?

Jan 23, 2014

what code I can put behind a button so that once I click on that button,

What ever cell i click on, the whole row of that cell will be colored a certain color.

Is this where i would used a target approach?

View 6 Replies View Related

Modify Macro In Excel / Transpose - Delete Contents - Skip X Rows - Repeat?

Mar 7, 2013

I have a list in Excel, and it has the company in one column, and it's information in the next x rows until there is a blank row (4-7 rows). I get that you can copy the rows under the Company, transpose next to the company, and then delete the contents of the cells that you just took the data from, but I have 6200 rows do to this to, for 500+ companies. I tried recording a macro for two entries, and this is what I have (see below), but how do I modify this so that I don't need to type in every single range, and it will do it to the whole column? The data is in column A, I am posting in column B.

Basics for Macro Requirement:

1. Find the blank cell in row A
2. Skip the next cell/row (this is the company)
3. Select all the cells beneath the company cell, until it reaches the blank cell underneath
4. Copy, transpose these cells next to the Company cell (transpose in column B)
5. Delete the contents in row A that were just transposed
6. Find the next cell with data (company)
7. Repeat Steps 2-6

My recorded Macro:

Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+q
'
Range("A3:A8").Select

[code]....

View 5 Replies View Related

Command Button - How To Delete Specific Rows

Mar 15, 2012

I have a command button that upon its click I would like to delete a specific row. I am using a vlookup which is giving me the row of the number I would like to delete. How do i go about deleting out this row?

this is also a radiobutton within the row that I would like to delete out as well. It is not named but it linked to column B within the row that I will be deleting.

View 3 Replies View Related

Macro Button To Add / Delete Rows Across Multiple Sheets

Jul 24, 2014

I've been piecing a macro together from different sites and have run into a couple issues I can't find resolutions to. I have a excel doc for tracking paint emissions per week. I would like to have a button on my master tab that will add a row and fill the formatting from the line above across all 60 some sheets. Ideally I would like the same button to first prompt if you want to add or delete rows. When adding rows I would like it to add it above the button (there's 3 buttons and for 3 different sections) and if deleting ask which row to delete. If it can't be done in one button that's fine, I can live with that. The big thing I need is for it to replicate across all of the excel sheets. I've attached a copy of the document

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

Clear Contents Macro

Jul 18, 2006

I have a protected worksheet in which certain calculations are performed based on certain inputs.

For example, let's take Column E:

Starting in cell E4, I have cells in that column which are input cells and further down the column are calculated cells which are locked and whose formulas are hidden.

I was looking for a macro which would go down col E and clear contents of all unlocked cells without messing up any of the protected cells.

Also, there are certain cells in which I want to clear contents and some cells that I want the macro to insert a "0" value.

The input cells are non-contigous.

View 7 Replies View Related







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