Delete N Rows From Active Cell

Jun 12, 2009

Is there a quick way to delete "N" rows from the active cell regardless of the content of the cells in those rows? I import text files into excel then frequently have to go through them and delete rows of nonimportant data.

For example if cell A57 is currently selected can I run a macro that will delete the next 10 rows?

View 2 Replies


ADVERTISEMENT

Delete Row Of Active Cell

Mar 26, 2008

I have a macro for deleting a row. I want iit to delete the row that I have selected, that is i if I mark cell B22 I want it to delete row 22. But it deletes the row under it, that is 23.

Sub Tabortrad()
Dim intRadnr As Integer
Dim intStartrad As Integer
Dim intSlutrad As Integer
intRadnr = ActiveCell.Row
intStartrad = ActiveSheet.Range("Första").Row + 1
intSlutrad = ActiveSheet.Range("Sista").Row - 2
If intRadnr < intStartrad Or intRadnr >= intSlutrad Then
MsgBox "Kan inte radera denna rad. Placera markören på en av bokföringsraderna mellan rad " & intStartrad & " och rad " & intSlutrad - 1 & "." & Chr(13) & "En ny rad kommer att infogas under den rad där markören står.", vbOKOnly, "Felaktig rad markerad".......................

View 2 Replies View Related

Delete Rows That Contains Zero And Copy Active Sheet To New Sheet

Oct 2, 2009

I want DELETE the rows that contains 0 (zero or -) in column F (SALDO BRUTO), when I click the Button (Clear). And How I can copy from this sheet to a new sheet in this workbook, but the names of new sheet automatic rename to next date or 2, and next when I click the Button "Copy to New Sheet".

View 2 Replies View Related

Insert Rows At The Active Cell

Aug 7, 2006

I want to be able to allow a user to insert a number of rows (they would specify the number) into a worksheet, at the active cell location. I also need the same number of rows to be inserted into the same worksheet (but much lower down) The location of which is to be governed by the location of the original inserted rows.

Having created the new rows I need all the formulas from the row ABOVE the active cell to be copied into all the newly created rows.

example
If active cell is A5 I want user to be able to run a macro which asks them how many rows they wish to insert. (Assume the user asks for 7).

The macro then inserts that number of rows, (starting at row 5). And additionally adds 7 rows at a location further down the worksheet (say row 105). The formulas from the row above the active cell are then copied into all the newly created rows.

2nd example
If the active cell was A9 then the macro would add 7 rows, starting at row 9 and additionally add 7 rows starting at row 109. Then formulas added.

View 9 Replies View Related

Macro To Print Active Cell And 6 Rows 4 Col

Mar 18, 2007

I have a workbook that need a macro to print current active cell
and the surrounding 6 rows 4 cols.

Also the selection printed need to fit
to page pref landscape on printing

the active cell varies day to

View 9 Replies View Related

Range X Rows & X Columns From Active Cell

Mar 19, 2008

Im writing a macro and have a cell activated (using ActiveCell). If I want to select this cell (the activated one - i.e., k3) along with the 2 cells next to it (i.e., l3, and m3), how would i go about doing that?

I'm wanting to shift 3 cells downward and I know how to shift them down, but dont know how to select the cells i want.

View 5 Replies View Related

Excel 2003 :: Highlight Cell On Same Row As Active.cell Whenever Active.cell Changes

Dec 10, 2012

whenever the active cell is within a given range, highlight the cell on the same row in column S (by changing its interior colour). This should occur each time the active cell is changed, whether by cursor keys or mouse. The effect would be similar to the row and column highlights at left and top of the worksheet.

This action should be restricted to one sheet in the workbook.

It's for Excel 2003.

View 3 Replies View Related

Selecting Range From Active Cell To Last Entry In Same Row As Active Cell

Jun 8, 2014

I have got stuck on one piece of my code and having trouble fixing... Overall I am trying to find variable station name in cell L2 of Sheet 2 in Sheet 1 and then select and copy the data from the data in "cell L2 of Sheet 2" to the last entry of that row. I have attached an example test spreadsheet of the data and a macro is within Sheet 1 called test1. Please note that cell L2 in Sheet 2 will always be different station name and the station list in Sheet 1 will change with differing station name.

The code I am using is:

[Code] .....

The code that is not working and bringing up an error is:

[Code] .....

Attached File : Copy of Testexample.xlsm‎

View 2 Replies View Related

Delete From Non Active Sheet

Nov 22, 2011

I am not sure why this code won't delete, I can't believe excel requires the sheet to be active to delete from. It will only work if the .activate line is included.

How can you delete from another worksheet without first switching to it?

Code:

'Sheets("sheet1").Activate
Sheets("sheet1").Range(Cells(row, col), Cells(row + 7, col)).Delete shift:=xlUp

View 3 Replies View Related

Delete Active Workbook

Oct 10, 2004

if it is possible to delete the current workbook that is open?

I'm thinking of using an add-in to delete the workbook i'm viewing

View 9 Replies View Related

Delete Sheets In Active Workbook

Nov 27, 2008

I want to create a macro to check through all sheets in an active work book, if a sheet is empty, then delete it?

View 2 Replies View Related

How To Delete Rows If A Cell Is Red

Feb 6, 2014

I am looking for a macro that will delete an entire row if the following condition is met:

If a cell in column B is red then delete that row.

View 14 Replies View Related

Delete Rows With Value In Cell

Jun 9, 2014

I have very large spreadsheets and need to delete rows where a certain cell equals a specific value.

Here's the logic, delete all rows where column U = "1900"

View 1 Replies View Related

Delete Both Rows If Cell Value Is Same

Jun 5, 2009

I am reconciling a bank statement. My numbers in column "A" are positive, The bank numbers,also in column "A", are negative.

In Column "B" I put an if statement- , If(A1< 0,A1*-1,A1), to get all entries to positive numbers and copied down.

I sorted the numbers in column "B" and now need a macro to delete both rows if they have the same value.

The total of column "A" is say $500.00 with 50 entires. After the deletion column "A" is still $500.00 but with only 10 items because all duplications were deleted resulting in my bank reconciliation.

View 9 Replies View Related

Delete Rows With Value Less Than Cell Value

Jul 21, 2007

i m trying to make a macro I have do an additional step. I have a column (D) in a worksheet that is showing time values (2:30 PM, 3:15 PM, etc.). I need to code the macro so a user can enter a time value and the macro will then delete any rows in that worksheet in which the corresponding cell in column D shows a time value LESS THAN the value entered by the user. I've seen a couple of macros that delete rows matching a string in a cell but nothing that deletes based on the cell value being less than. Also - I need this to be done as a macro. I know how to filter the column manually to get what I want but I need this as a macro so people who are not familiar with Excel can simply open the workbook (I have the macro set to run automatically), enter the time value (ex. 2:30 pm) and they'll get all the rows in which the time is greater than or equal to 2:30 pm (the rows with an earlier time having been deleted by the macro).

View 2 Replies View Related

Delete Rows Where Cell Doesn't Equal Adjacent Cell

Aug 16, 2007

I have a sheet in Excel 2004 for Mac that is a patient list with over 2000 patients. I need a rule that will compare values (patient IDs and responsible party ID) in two adjacent cells, if the values are different, to delete the entire row. The goal is to get rid of patients (rows) that are not the responsible party (responsible party ID).

View 3 Replies View Related

VBA - Delete Sheets In Active Workbook According To Combobox Value

May 8, 2014

That particular question has been solved, but now i need it to work with multiple values from combobox.

So for example,
if "Master" is selected in combobox3, it will delete sheets 7, 8
if "CSR" is selected in combobox3, it will delete sheets 1, 8
if "Original IND" is slected in combobox, it will delete sheets 1,7

The current code will work when "master" is selected, however i am getting compile errors when i select "CSR" or "Original IND"

WhenI select CSR, it does create a new wb for me (without sheets 1,8) correctly but i get a Run time error.

Run-time error '-2147417848 (80010108)': Automation error

The object invoked has disconnected from its clients.

When Original IND is selected, i get a compile error and it highlights 'Make the new workbook active newWBK.Activate

View 5 Replies View Related

Select Active Cells And Delete Entire Row

Oct 30, 2012

I have data that i import on a daily basis, the data can range from a couple of rows to thousands,

What I need to do using VBA is select the active cells, where cells in row ''G'' is blank then delete the entire row where that cell is.

View 3 Replies View Related

Delete Shapes But Not Active X Controls Box On Same Sheet In VB

Mar 12, 2013

I have an active x control command button on the same sheet as some shapes (lines,circles) which are generated from some parameters. I want to be able to delete the current shapes so I can plot the next shape. Below is the delete shapes part of the code, not sure how to complete the code.

Currently, the box is getting deleted as well as the shapes

Code:

Private Sub CommandButton1_Click()
Dim line1_Beginx As Single, line1_beginy As Single, line1_endx As Single, line1_endy As Single
Dim line2_Beginx As Single, line2_beginy As Single, line2_endx As Single, line2_endy As Single

[Code]....

'Calculate positions of line vertices for plots

line1_Beginx = 1000
line1_beginy = 1000
line1_endx = 1000 + CD_2
line1_endy = 1000

[Code]....

View 2 Replies View Related

Delete All Rows Where Cell Value Is Number

Jul 6, 2014

I have the code below which is doing all I need it to do, except I would like to add a line that deletes all rows where the cell value in column "F" is a number:

The main thing is I can delete all rows if the value in column "F" is a number.

Idea Being, it:
-Deletes all rows where value in column F is blank.
-Then Deletes all rows where value in column "F" is numeric.
-Then deleted all rows where value in column "F" is any value specified in Column A is sheet 2.

[Code] .....

View 3 Replies View Related

Delete Rows Without A Specific Value In A Cell

Jun 2, 2008

I have 2 spreadsheets of delivery information. Sheet 1 contains data of all stores in the UK with addresses. Sheet 2 containts contacts of all stores that promotional matrial needs to be sent to.

The only common cell in a column of 4 digit store numbers.

I need to delete all rows from sheet 1 that do not contain a value in the store number column that is displayed on sheet 2.

View 11 Replies View Related

VBA Delete Rows In Between Cell Values

Oct 13, 2012

Within one column, there are cells with values A, B, and C for example. I want a loop that
- delete all rows from the first row to the row where A occurs,
- delete all rows BETWEEN where B and A occurs.
- and then finally, delete the single rows where C occurs.

This might seem I'm just deleting everything but obviously there are more "A" and "B"s in the column.

1
2
3 A
4
5 B
6
7 A
8 B
9 C
10

So in this example, rows 1 to 3 are deleted since I want to delete row 1 to the row where A is; rows 5 to 7 are gone (B to A); then finally row 8 is gone since C is there. Whether it's A/B inclusive doesn't matter..I just would like to see the (simple) logic.

View 9 Replies View Related

Delete Rows Based On Cell Value?

Jul 6, 2014

I am looking to make a cell with the Value =Today()-1. I then want the code to pick up the cell value and then delete any row that does not have that value.

So for Example it would only keep =Today()-1 Dates in the sheet and delete the rest.

Code:

Dim LR As Long, i As LongWith Sheets("Sheet1")
LR = .Range("Q" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If .Range("Q" & i).Value = "Y" Then .Rows(i).Delete
Next i
End With

View 9 Replies View Related

Delete Rows Between Two Cell Values

Jan 28, 2010

I have rows between the Words "vendor" and "sales order" both words are in column A. The number of rows is never constant but needs to loop through the whole document. Is there a way to make a macro to do this?

View 9 Replies View Related

Delete Rows From Set Row Until 1st Empty Cell

Sep 25, 2008

I have an excel sheet where within my macro i want to delete some rows in the middle of my spreadheet. The number of rows to be deleted can vary so I want to know the code i can insert so it can find the number of rows with data and then delete them.

Currently, i have it working where i go to the top of the data and do End + Down and delete those entire rows. However, the problem is when i only have one row of data then the End + Down goes down to cells i do not want to delete. How can i overcome this?

This is my code to delete the rows:

Range("C40").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Range("A1").Select

As mentioned, this does't work if i just have one row of data. The data always starts at row 40 but can be only one row or more rows beneath this.

View 5 Replies View Related

Delete Specific Type Of Chart From Active Sheet

Feb 20, 2009

i'm trying to delete a specific type of chart from the active sheet using this macro:

View 2 Replies View Related

Delete ALL Rows That Have Cell In Column (J) That Looks Blank

Feb 11, 2010

I'm trying to delete rows which has columns that appears to be blank. Below code worked fine but it took about 15 min for the macro to work through the spreadsheet.

View 2 Replies View Related

Code To Delete Rows After Selected Cell

Sep 24, 2011

I've got a sheet that I build from a weekly sheet. I can have 30 to 60 rows, but I always have 10 to 20 rows left over with data in column C, none in A, my last code is "Range("A1").End(xlDown).Offset(1, 0).Select" which takes me to the last cell in column A. Any code that I can then delete say 20 rows after that? I tried one code, but it wanted to delete everything below the cell selected which ran & ran.

"-" are blanks. Range moves the selected cell to A4. I want to delete row selected + 19 more.

-|A|B|C|D
1|Y|2|9|J|
2|R|1|8|N|
3|G|4|7|N|
4|-|-|L|-|
5|-|-|L|-|

View 9 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 Matching Cell, Across All Worksheets

Aug 20, 2006

in VBA, I would like to do the following:

Delete the entire row where any cell in that row is equal to cell "b15" in worksheet "Metal Type".
I would like it to run across all the worksheets hidden or unhidden, in the workbook, (except for worksheet "Metal Type").

If possible I would also like it to prompt the user to accept the contents of cell "b15" in worksheet "Metal Type" or enter a new string.

Also can it alert the user when "no matches were found"

View 9 Replies View Related







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