Macro To Clear Rows On Another Sheet

Aug 12, 2008

I have a macro that copies data into another sheet (OR) from sheet1 (EDS) but as I don't want the data added from the last row I want it to overwrite and clear any data that was there before. However I still want to keep my headings which occupy rows 1 and 2.

This is the code I was using...

Sheets("OR").Select
Rows("2:30").Select
Selection.ClearContents
Sheets("EDS").Select

This is pretty inefficent but it works. I don't want to make a new macro I like keeping it inserted in my current one. However I couldn't figure out how to get it to delete the rows past row 2 (it could go to infinity but I don't think there will ever be more than 30 rows of data).

View 7 Replies


ADVERTISEMENT

Clear Rows Vs. Deleting Rows To Avoid #REF! Formula Error - Macro

Jun 9, 2009

I have a macro which is copying data from several worksheets into one consolidation worksheet. When determining where to paste the data into the consolidation sheet, the macro includes some logic to find the last row that has data in it (using e.Range("A65536").End(xlUp).Row, where "e" is a variable holding the name of the consolidation worksheet).

Once all the data is on the consolidation worksheet, I have a second worksheet with formulas that link to the consolidation sheet. The issue I have is that the first step of my consolidation macro deletes all data on the consolidation sheet to ensure that no data is double-counted). I am deleting the data with logic that simply deletes all rows from 3 to 65536. Once these rows are deleted, Excel returns a #REF! error on my second worksheet which is linking back to this data.

Rather than deleting the rows on the consolidation sheet, I have tried using the Clear and/or ClearContents commands instead. This works (i.e., my formulas no longer error out), but results in the consolidation macro running very slowly (~15 minutes, compared to

View 9 Replies View Related

Keep Macro From Clear Entire Sheet

Feb 25, 2014

This macro clears all the contents of each sheet to which it refers, however, after putting it to use I find that I need it to clear only columns A-G starting at row 10. I am not sure how to modify it to do so though. Actually it would be even better if it would only clear columns A, B, C, E, F, and G.

View 14 Replies View Related

Clear Sheet Contents Before Continuing With Macro

Dec 1, 2009

Im looking to ensure the sheet contents are clear before continuing with the macro routine. At the moment however, the macro runs I see the data flash up and then off. So it appears the data is being cleared as soon as it loads. Current code is:

View 2 Replies View Related

Macro: Print Sheet & Clear All But Heading

Nov 13, 2006

is their away to print a sheet/s and after printing to delete the contents but still leave a title

View 9 Replies View Related

Create Macro To Copy Sheet - Clear Cells And Add A Day

Jul 8, 2013

I am looking to create a macro to copy sheet Day(1) and call it Day(2). I would like Y3 to increase one day with the date, I would like Y4 to increase day and 1 and clear data from G35-G65.

View 4 Replies View Related

Macro To Clear Row Data Then Shift Remaining Data Up To Empty Rows?

Apr 15, 2014

I'd like to have a sheet with multiple columns of data (say A thru K for instance.). Id like to reserve column A for ONLY imputing an X. The rest of the columns b-K would have data in the cells. I'd like to have a macro that when it saw an X in column A, would copy all of the data in cells B-K in that row, paste it into the next empty row of a second sheet (for history tracking), then go back to the original sheet and continue looking for additional "X"'s and repeat. Once all of the X's were copied, it would "clear" (Not delete because some of the cells would have formulas in them that would need to remain for future use.) the cells based on the "X" then finally move all of the remaining data up to the empty rows to fill in the empty rows. This last piece would be more for esthetics to have a clean looking sheet.

View 1 Replies View Related

Clear Macro NOT Clear Formula?

Aug 15, 2014

I'm having a problem with a macro clearing a formula in a cell. I have the same type of cell that doesn't have the problem but I can't find the difference between the 2 cells or difference in vb that's making it happen. I have to intentionally cause this to happen but don't see why it's happening. Do I need to attach workbook and describe what's happening? I have been copying and pasting from different sources as well as paying to have it created/started but it was expensive(for me) and I make nothing off of it, just use it at work. I am not proficient in Excel or vb but I'm desperately trying to learn as I go so as not to fork out a few hundred dollars again.

here's atleast the vb for the macros:

VB:
Sub clearclientinfo() '
'
'
'
Sheet5.Select

[Code].....

View 9 Replies View Related

Macro To Copy Rows Based On Moving Date And Paste Rows Into Identical Sheet

Jan 28, 2014

I need to build a macro which copies 3 rows every day and pastes the row data into an identical sheet. The three rows will have column "D" as =today(). As the days progress the three rows will change accordingly ( tag to the today's date)

e.g. 28/1/2014
28/1/2014
28/1/2014

I need the macro to recognize the date when pressed and copy the corresponding rows of data and paste them into an identical sheet with the same date. The second sheet is an archive sheet. The date will tick over as per the calendar.

View 9 Replies View Related

Macro For Copying Rows Of Data In Sheet 1 To Sheet 2

Oct 8, 2009

I have a couple of spreadsheets that requires me to copy data from Sheet 1 that matches certain criteria to Sheet 2.

I have tried using posted VB codes that have been written for other people but they dont seem to work (this is probably to do with me not actually knowing what I am doing, as I am not sure what I should be replacing and what I need to be deleting etc out of the pre-written code )

I need to be able to search on column e in Sheet 1 for anything that has just h written in the cell and then copy all the rows that match into Sheet 2. I also would like to ensure that when it is copied it doesnt go in row 2 but maybe 4 or 5 as I have quite allot of headings.

View 9 Replies View Related

Clear Sheet

May 4, 2007

How can I clear all elements in a sheet, including charts with vba code?

or

How can I select all chart in a sheet and then delete them?

View 2 Replies View Related

Clear All The Rows Where The Numbers Match

Dec 6, 2007

I am working with a file where I have to clear all the rows where the numbers match. Lets say if there is a row in which /in the amount column/ there is a number: 53 and have another row where /in the amount column/ the number is -53 I can match these two rows and put them to a new sheet. So what I would like to have is something which sorts out all the rows in which the amounts can be matched out. Like 53 and -53, 23587 and -23587, 98 and -98. Is it possible to have something like this? Sorry for the language..

View 14 Replies View Related

Automatically Clear Rows When Condition Is Met

Feb 6, 2009

I've got a workbook (attached) with a "summary" sheet & 2 detail sheets for tracking vacation time used, and I need to make it automatically clear out an employee's "used" vacation hours automatically on their anniversary date.

Can anybody help me please? I've had no luck thus far & "the powers that be" are really getting on me for this now -

View 14 Replies View Related

Completely Clear All Rows After Date

Mar 4, 2009

Is there some vba code that will completly remove all rows after a certain date in A column, the date is in B2. Dates are listed in A column.

When i say completely remove i mean delete, clear colours, remove borders,etc etc

View 7 Replies View Related

Macro For Moving Rows To Other Sheet

Nov 29, 2006

I'd like to write some code to do the following: When the first cell of the row contains an "Y", move the entire row to another sheet (in the same file), keeping in mind that this sheet already contains some rows (so add the row on the first empty row in the sheet). Afterwards the original sheet contains no longer any rows in which the first cell is filled with an "Y".

View 4 Replies View Related

Macro For Copying Certain Rows To Another Sheet.

Oct 20, 2009

I'm trying to create a macro that examines a sheet of data, and if the data in a certain column (column P) contains either A,B, or C then it would copy the entire row over to another sheet. If it contained a blank or D,E, F, etc,etc then it would just ignore that and move to the next row.

I have no idea where to start, i've searched google and here on Mr.Excel.

View 9 Replies View Related

Clear Object In Sheet

Apr 10, 2009

I have many objects in a sheet, for example Picture(from file), Oval, command button... I want to clear these objects. How can I do ?

View 3 Replies View Related

Clear All Filter In A Sheet?

Nov 15, 2013

to clear all the filtering done to the sheet at once. Sometimes it works properly and sometimes it isnt.

Code:
Sub Cleardatafilter()
ActiveSheet.Unprotect "MyPass"
If ActiveSheet.AutoFilterMode Then

[Code]....

View 3 Replies View Related

Clear Range On Another Sheet

Apr 18, 2008

I have used the VBA and it works to select all data but I have an issue when there is no data to select beneath the column header. I am running this on multiple worksheets which vary with data week to week.

Sheets("sheet1"). Range("A6:G" & Range("G" & Rows.Count).End(xlUp).Row).Offset(0, 0).Select selection.ClearContents

How can I run this and not have it delete the column header when there is no data? Is there a way to change the formula so that it selects all cell columns of data without defining it?

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

Clear Content & Formatting Of Hidden Rows

Aug 19, 2009

I am trying to return the range of cells that is not in a range of cells.

Dim rge As range
Set rge = activewindow.visiblerange

'set rge2 = cells not in rge 'HERE IS WHERE I NEED HELP

rge2.clearcontents

I am trying to avoid a for each style loop.

View 5 Replies View Related

Clear Rows Meeting Multiple Criteria

Dec 13, 2006

In my code I am searching a spreadsheet for certain states and deleting rows that have states I want to exclude. Is there a way to do this with a list of states, instead of having to make many for loops?

For i = lastrow To 2 Step -1
Cells(i, 4).Select
If Cells(i, 4).Value = "PA" Then
Rows(i).Select
Selection.ClearContents
End If
On Error Resume Next
Next
For i = lastrow To 2 Step -1
Cells(i, 4).Select
If Cells(i, 4).Value = "TX" Then
Rows(i).Select
Selection.ClearContents
End If
On Error Resume Next
Next

View 5 Replies View Related

Macro For Deleting First Three Rows In All Sheets Except 1st Sheet

Apr 1, 2014

I have a excel file with more than 10 sheets and every sheet has a title on its first three rows.

I want to delete first three rows in all sheets except parent sheet .

View 4 Replies View Related

Macro To Move Rows To The Bottom Of Sheet

Apr 24, 2009

I am attempting to write a macro so that when a user selects enters a particular selection in a cell, it will automatically move the entire row down to the last row and shade it in a different colour.

View 9 Replies View Related

Clear Filters From Inactive Sheet VBA

Dec 15, 2009

In VBA, is there code to clear all filters from an inactive worksheet or does the worksheet need to be activated?

View 14 Replies View Related

VBA To Duplicate Sheet And Clear 2 Cells

Jun 8, 2009

I have a spreadsheet that I have created as a door schedule for faculty members at our institution of higher education. The intention is for them to fill-in their office hours and courses along with a few other bits of information. One sheet should have their teaching and office hours and one sheet should not.

These are the cells that should be cleared once the sheet has been duplicated (F30, F31, G30, G31). Once the sheet is duplicated and those two cells' contents has been deleted, both sheets should be printed. Ideally, all of this would be initiated by clicking a hyperlink or something like that.

View 9 Replies View Related

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

Macro To Copy Rows From Data Sheet To Worksheet

Apr 23, 2014

I have two worksheets.

Worksheet 1 is a large data sheet containing columns of data (Date, State, Payment Method, etc, etc)
Worksheet 2 is the 'Report' worksheet with 2 blank cells (A1 and A2) for users to manually enter the Start and End dates, a drop-list for State names (B1) and a drop-list for Payment Method (C1) - Cash or Credit Card.

How can I write a macro to:

1) Filter by Start and End Dates then,
2) Filter by State name then,
3) Filter by Cash or Credit Card then,
4) Copy these filtered records (i.e. whole row/s) onto the 'Report' worksheet starting at Column A, Row 5.
5) Macro to end with a 'Successful' message.

View 1 Replies View Related

Listbox Macro To Hide / Unhide Rows In Different Sheet

Jun 27, 2014

In the attached abbreviated example, what should the second line in each of the three macros read to direct the hiding/unhiding of rows in the adjacent sheet? Right now I'm trying a If/Then configuration but it's not working. I was able to figure this out using grouped check boxes but a list box should be graphically "cleaner" and hopefully simpler in coding. The original table list is hidden in column "A", if that is important. I could use a combo box but the menu list is short and I think the list box approach will be simpler.... If there is a way to combine the three macros into one.

View 2 Replies View Related







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