Clear Used Range
Feb 21, 2010
I have a table on a worksheet and have for quite some time used a very successful macro UsedRangeClear. I found here on the forum. Anyway the macro still works on all tables on all other sheets except this one. This is the reason, somehow someone, maybe even me, copied something down or formated down to the 1,048,152th row of the worksheet. My workbook has grown from 5000 kb to 11,000 kb.
I have tried to highlight and deleted the rows, highlight and clear contents and the following macros:
Sub UsedRangeClear()
On Error Resume Next
ActiveSheet.Unprotect Password:="myfadra"
Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveSheet.UsedRange
ActiveSheet.Protect Password:="myfadra"
End Sub
Sub ReSetTable_UsedRange()
'For ICFMR
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).row
On Error Resume Next
ActiveSheet.Unprotect Password:="myfadra"
Application.ScreenUpdating = False
Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveSheet.ListObjects("Table7").Resize Range("A1:T" & LR)
ActiveSheet.Protect Password:="myfadra"
Application.ScreenUpdating = True
End Sub
Each option freezes Excel. I am sure there is something easy I am just missing. Soooo, Please offer any suggestions you can think of.
A Loyal Mr. Excel Follower
Alecia
View 9 Replies
ADVERTISEMENT
May 8, 2014
I need a simple VB Code to clear the cell :
K106 = BI210:BU269
Need to clear the range BI210:BU269
if K106 = BI271:BU341 then need to clear range BI271:BU341
View 2 Replies
View Related
Nov 28, 2006
I'm wrinting a macro to copy specific data from a table. To do that I'm using a Autofilter and a list of criteria. The macros works fine for existent data, I'm mean, when the result of the filter is not null, but when the filter doesn't find a result, instead of clearing the filter range, it keeps the last valid. The result is a colapse and freeze the Excel. I'd like to know how can I reset or clear the filter range?
The code I'm using is:
Sub Filter_01()
'Definições preliminares
Dim rng As Range
Dim rng2 As Range
Dim ARLE
Dim filter_valid, filter_invalid As Variant
filter_valid = Array()
filter_invalid = Array()
'Criação do Arquivo de Destino
Caminho = "D:Documents and Settingscjcs.ABMeus documentosAutomaSIPPPlanilhas"
Nome_Arquivo = "Produtos_Tanques.xls"
Nome_Completo = Caminho & "" & Nome_Arquivo ...
View 9 Replies
View Related
Jul 19, 2007
I have a macro to clear all contents for a sheet in a workbook. The problem is that every file has over 20 sheets of data. Is there a way I can code a for statement to clear all sheets in this one workbook? Is it possible to make a for statement for multiple workbooks with several sheets?
Range("A11:Z11").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.ClearContents
Selection.Interior.ColorIndex = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.ClearComments
View 9 Replies
View Related
Aug 31, 2007
why the first version below works but the second doesn't
1st
ThisWorkbook.Worksheets("GBP%"). Range(Cells(8, c), Cells(z, c)).ClearContents
2nd
Worksheets("GBP%").Range(Cells(8, c), Cells(z, c)).ClearContents
c = 16 (uses a for statement to go through columns 16 to 111)
z = in this case 24, but is dynamic depending on number of files in a list
Currently using Windows 2000 with office 2000
View 6 Replies
View Related
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
Jun 18, 2008
is it possible to clear the value in a range variable?
For example say:
Set A = Range("B4")
Is there a way to clear the value of that range, in other words make it blank again? And unfortuanlly i can't just make it equal to another range i need it to be blank.
View 6 Replies
View Related
Jun 15, 2014
I have
colpaste1 =Range("D2:D2")=BA
colpaste3 =Range("D4:D4")=BC
If Cell D2 = BA and D4= BC, i need VB Code to clear all contents in column BA to BC.
Note: BA and BC are the columns.
View 2 Replies
View Related
Jul 8, 2009
This seems to take much longer than I would have expected. Is there anything I can do to speed it up, or is this just something to live with?
View 13 Replies
View Related
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
Jun 19, 2009
I am trying to create a marco that clears the columns of a named range if the sum of the cells in the range is zero.
View 3 Replies
View Related
Dec 26, 2013
I need a macro that will clear the contents of all cells shaded white in range c1:c20.
Clear the contents, leave the cells shaded white.
View 1 Replies
View Related
Mar 28, 2007
I am trying to write a macro in excel to clear all cells within a range that are non numeric. I seem to be going round in circles trying to find out how to do this.
I assume I have to use the IsNotNumeric(Target) argument but I can't find how to specify the target within a range.
View 9 Replies
View Related
Jul 13, 2007
I want to clear the range A10:IV65536 or all the cells containning numbers under the row A10.
Right now it takes for ever to clear it mannually because excel recalculates everything... i have over 100 000 data and id like to find a way to delete them quickly.
Is there a way to clear a range without excel recalculating everything???
If not the best way i think would be to clear the last columns first all the way to the first columns.
View 9 Replies
View Related
Jul 21, 2006
I'm trying clear the contents of a column range when the cell above this column range is empty. I know how to do this for one cell, but I would like it to work for a rangefrom R15:BB15.
If IsEmpty(Range("r15")) Then
Range("r16:r35").Select
Selection.ClearContents
End If
End Sub
View 5 Replies
View Related
Aug 22, 2006
i need a macro that will select 0's in columns h-j.
View 7 Replies
View Related
Jan 10, 2007
I am filtering column S in a sheet to show all rows with a date after the end of the previous month - i.e. >= 01/01/07. What i want to do is clear the contents of those visible cells in column S. I tried the code below (got it on this site) but it works its way up from the bottom of the sheet until it finds the first visible row and then clears the contents of column S in each row above it, whether it is visible or not.
Sheets("Planning").Select
With Range("e2:C2")
.AutoFilter field:=5, Criteria1:="<=" & Sheets("Filtered Statistics").Range("c3")
.AutoFilter field:=19, Criteria1:=">=" & Sheets("Filtered Statistics").Range("d3")
For i = Range("s65536").End(xlUp).Row To 3 Step -1
If InStr(1, ">=" & Sheets("Filtered Statistics").Range("d3"), Cells(i, 19).Value) = 0 Then
Cells(i, 19).ClearContents
End If
Next i
.AutoFilter field:=19
End With
View 2 Replies
View Related
Jan 11, 2007
I found a way to import some data from some csv files, and it works well for me. I don't want to keep the option to refresh the data. I can go into each tab created from each import and and uncheck the box Data>Import External Data>Data Range Properties>"save query definition" that removes it for me. Is there a way to do that with code. It doesn't work with the macro recorder.
Sub ImportOnline()
On Error Resume Next
Dim DayFile As String
DayFile = InputBox("Enter Date of File (MMDDYY)")
Sheets.Add
ActiveSheet.Select
ActiveSheet.Name = "B-" & DayFile
Application.ScreenUpdating = False
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:My DocumentsB-" & DayFile & ".txt", _
Destination:=Range("A1"))
.Name = DayFile
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False................
View 3 Replies
View Related
Sep 17, 2007
I have a dynamically named range the contents of which I want to clear. However, I also want to clear the cell contents in the next column beside the range. So if my dynamically named range is A20:B40 can I clear the contents of A20:C40 without changing the initially named range. Background: The data I have is the result of an advanced filter. The range is named for printing purposes without the final column.
If I then change one of the raw data I want to run the filter again. To do this I need to clear the first filter.
Range("AIT_Change_Management").ClearContents
View 7 Replies
View Related
Jan 19, 2008
I am trying to code a command button to clear a range of cells if any of them contain a numeric value. For example. If any cells of cell range A1:C10 contain a numeric value then they would be cleared. Not all the cells in the range but only thouse contaiing numeric values. I have tried various methods with not-so-good results.
View 9 Replies
View Related
May 5, 2008
is it possible to refer to ranges by using index numbers?? I am looking for something like: (which I tried but does not work..)
Worksheets("Sheet1").Ranges("Cells(counter,1):Cells(counter+10,10)").ClearContents
View 4 Replies
View Related
Jun 6, 2008
For various reasons I need to copy a the range "a2:s251" in the sheet "FWD Input" to another sheet but I need to remove any formulas.
To do this I have used the
Sheets("FWD Input").Range("A2:S251").SpecialCells(xlCellTypeFormulas).ClearContents
This works fine if there are formulas in that range, however if there aren't it gives me: " Run time error: 1004 No cells were found"
So I think I need some code that counts the number of cells in the range with formulae in them and either goes ahead if there are some or quits if there aren't.
View 3 Replies
View Related
May 17, 2008
I am currently trying to write a macro that will search a column for different strings. These strings are inside the cell (as in it is not the only value in the cell) and then copy the entire cell over to another column, then delete the two cells to the right of the originally found cell.
Heres an example of what I want to:
There are four columns, the first has a name with both the first and last (amanda white)the second just the first name (amanda), the third just the last name(white), and the forth an organization name. if the first column contains an organzation name, it has to clear out the first name and last name columns, and copy the name column to the organization column.
NAME | FIRST | LAST| ORG|
amanda white amanda white
mike jones mike Jones
pizza hut pizza hut
I have a list of organization keywords to search the first column (e.g. enterprise, variety, management, pizza). I want it to recongnise the "pizza", copy that entire cell over to the organization column and delete the first name and last name for that row.I've been trying to modify a code like this but i can't seem to make anything work.
VB:
FindWhat = "pizza"
For Each Cell In Range("B2", Range("B" & Rows.Count).End(xlUp)) [code]....
View 5 Replies
View Related
Apr 27, 2014
Looking to code a loop to go to sheets whose names begin with "day" and a number and clear a specific range. How would i code this without affecting the other sheets in the book?
View 3 Replies
View Related
May 15, 2014
Looking for some code to clear cells which are not highlighted
i.e. clear everything from row 2 downwards (Columns I:P) but exclude cells which are highlighted (not conditional formatting)
View 3 Replies
View Related
Aug 3, 2014
I am currently working on writing a macro that clears all rows in which the cell in column F doesn't say "Sale", "Purchase", or "Tax Code Description", however, I keep receiving an error that says "Wrong number of arguments or invalid property assignment".
[Code] .....
Also, I originally was deleting the rows, but I have formula's pulling from this tab and need them to not lose their reference after the macro executes.
View 2 Replies
View Related
Feb 11, 2014
I have a range variable named data I want to clear all the data in the 3rd column in the range variable I know how to reference a single location in the range variable but not a whole column. see example code below
[Code] .....
View 3 Replies
View Related
Nov 5, 2008
I have a range on worksheet "CONTROL" from S129:S228. There are 100 rows there. I have another range on the active sheet from B17:N116, also 100 rows. If S129 has a value of 1, then I need row 17 on the active sheet to be cleared (columns B-N). And so on all the way to the bottom of the ranges. If it has no value in the cell, then no clearing takes place. So it needs to test the whole range at once. I really have no clue what the variants and ranges should be, and have NO CLUE how to define a variable range so that I can use the value that R is on in the testing cycle to tell the active sheet which row to delete.
View 3 Replies
View Related
Jan 4, 2009
I want to have users fill out. While it is possible to have it Read Only so that they always SaveAs I would rather put in a macro to clear the user input fields. I have done this in Excel 2003 and when I try using the same techniques in 2007 I get an Error 400.
I have all the cells (some are merged cells) in a named range and have the following code for clearing them.
View 3 Replies
View Related
Jan 17, 2013
Is is possible to clear the contents of a cell range if a message box appears stating an error. I have tried the following code but the logic doesn't actually work and am struggling to achieve what I am trying to do.
My code so far is as follows:
Code:
If ActiveSheet.Range("F84") > 0 And ThisWorkbook.Worksheets("PES").Range("D24") = 0 Then _
MsgBox "Your Entitlement is currently 0", vbCritical, "Error"
ActiveSheet.Range("K84:T84").ClearContents
The message box appears fine if the IF statement is true but if IF statement is false, the cell range of K84 to T84 on the current sheet is still cleared..
View 2 Replies
View Related