VBA Code - Delete Specific Range Of Cells?

Apr 15, 2014

I wanted to ask how to delete a specific range of data in a cell range using VBA

Here is a snipit of code I currently have:

Sname1 = Sheets("Numbers").Range("FX3").Value 'FX3 = cell F starting column letter

Range(Sname1 & Range("FR7").Value).Select 'FR7 = row number

If I added the following:

Sname2 = Sheets("Numbers").Range("FX4").Value 'FX4 = cell n ending column letter

Changed the code to the following: obviously this code is incorrect below:

Range(Sname1 & Range("FR7").Value) : Range(Sname2 & Range("FR7").Value).Select

View 3 Replies


ADVERTISEMENT

Delete All Cells In Range NOT Containing Specific Value

Mar 1, 2014

Not sure if this is better suited for a macro or done via conditional formatting.

Trying to empty a standard template we use and of a certain range I need to empty all cells not containing N/A (typed not error).

View 2 Replies View Related

Delete All Duplicates (all Cells) In Range Specific

Apr 20, 2013

I need a code to delete all duplicates (all cells) in the range A1: F100?

Exemple:
Before
31
81
43

[Code]....

View 5 Replies View Related

Delete Rows With Blank Cells In A Specific Range

Feb 23, 2010

I need a VBA to delete rows with blank cells within columns F - AZ
Columns A - E contain headers but also need to be deleted if cells in columns F -AZ are blank.

View 9 Replies View Related

Code To Delete Whats Written In A Range Of Cells

Oct 19, 2009

I use this code to delete whats written in a Range of cells ...

View 6 Replies View Related

VBA Code To Delete Rows If Specific Value Is Not Present?

Aug 6, 2014

I'm trying to write a macro to update a report including deleting all rows that do not contain a specific value of TP in column K. Below is one of the examples.

[Code] .....

View 3 Replies View Related

Specific Cells Populate With Specific Numbers When A Value Within A Range Is Entered

Oct 9, 2009

Here is what i am trying to achieve. If the date 2/20/2010 is located at F53 & the cell next to it at H53 is populated with a number between 1 & 16, then i want the cell at J11 (42 rows further up) to auto populate with the number 1. When this occurs the cells beneath this, from J12 to J52 should also auto populate with the with consecutive numbers from 2 to 42. Would also like to see the cells with numbers 1 to 28, automatically format to orange & the cells containing numbers 29 to 42 automatically format to yellow. I plan to have this condition repeat several times later in the year, at dates that are to be decided. When these dates are decided i want to be able to enter a number from 1 to 16 & next to the date & all of the above automatically occurs.

View 14 Replies View Related

Macro To Delete Specific Range Of Rows

Jul 12, 2014

I currently had to start from scratch as my formula kept raising the debug screen. I know the answer is simple but I cant figure out what it is. I have column A, rows 9 through 1000 with data. I want to delete the entire row of any "x" value present in column A rows 9 through 1000. I am new to VBA. So simple is good.

View 2 Replies View Related

Delete Range Names Containing Specific Word

Jun 6, 2008

the active sheet contains a number of defined named ranges. i would like to delete range names beginning with "Sales", yet the number of defined ranges changed from sheet to sheet = for example, Sheet1 may have 3 defined ranges (Sales1, Sales2, Sales 3), Sheet 2 may have 1 (Sales 1). Is it possible to included a wildcard search in the following code?

Sub DeleteRangeNames()
Dim RangeName As Name
For Each RangeName In Names
ActiveSheet.Names(RangeName.Name).Delete
Next RangeName
End Sub

View 3 Replies View Related

Delete Rows Where Cells Don't Contain Specific Value

Feb 27, 2013

If I have a column of data called "ColStream" and want to delete all rows that don't contain the string "Production", whats the best way to achieve it?

I have tried a for each loop, with INSTR but as this moves down a cell from the cell whose row has just been deleted, skipping the "NEXT" row in the range, it doesn't give the correct results.

Incidentally, the end game is to copy all the remaining cells to the cell immediately below a cell called "StreamsDatabaseStart" in a worksheet called "ProdStreams" should anyone out there be feeling particularly charitable!

View 4 Replies View Related

If Target Equals To 0 Then Delete Specific Cells On Same Row?

Mar 14, 2014

I'm Trying to write a code to delete Value in Column E & F If value in Column A = 0. (same row)

I've tried a few methods but none of them work.

View 2 Replies View Related

Delete Row Code And Set Range

Jun 16, 2009

See attached workbook. If you hit the Export button (runs Export Macro), it creates a new workbook. Most of what I have in the code works fine except the following bit:

View 2 Replies View Related

Code To Delete A Range?

Jun 17, 2014

I have a sorted range from the highest to the lowest in range B8:B50000. I need to find the first cell with zero value and last cell with zero value in this range. Then the these rows are selected and deleted.

View 4 Replies View Related

Using Macros To Delete Cells And Rows Based On Specific Criteria?

May 7, 2012

Each week I run a report that produces over 2,000 rows. I have to manually go through and delete things, by the time I am done, there may only be 320 rows left. I would apply a recorded macro, but the report is not consistent each week. There may be more or fewer rows depending on the week.

I would like to be able to run a macro that looks in column B for a specific value and if it contains that specific value, I would like the cells to the right of it to have their contents cleared.

Next, in column C, I have...

Employee2's Name
Employee2's Number
SPACE

[Code]....

I would like to be able to delete the rows, starting from Employee 2 to just before the second SUB TOTAL.

So, all I would have left in column C is

SUB TOTAL
SPACE

View 9 Replies View Related

Delete All Range Names Macro Code

May 13, 2008

I have written VBA code which is operated every month. This code deletes several range names in a target spreadsheet, performs other actions - including extracting certain areas to different spreadsheets and then closes the spreadsheet without saving.

The range names in the target spreadsheet are required for ongoing use, so can not be deleted permanently.

Is there any code that deletes all range names in one go? At present my code includes the results of recording a macro wherein I delete each range name in turn - creating script over 100 lines long.

View 3 Replies View Related

VBA Code For Selecting Specific Cells Within Worksheet?

Aug 28, 2013

know the VBA script to select only specific cells within a worksheet. To be more precise, on sheet 1 - A2, A6 and A10 cells are filled with red color. I want only those cells which are highlighted in red to be selected, copied and pasted to sheet2.

View 3 Replies View Related

VBA Code For Deleting Columns With 0 Value In Specific Cells

Oct 24, 2008

I am trying to write a VBA code in excel to delete any columns when a cell in that particular column = 0 (zero). That cell would start at B19 and subsequently follow to C19, D19 and so on.

View 9 Replies View Related

VBA Code To Unmerge Cells On Specific Worksheets

Jan 27, 2010

I have a workbook with multiple worksheets. On some of those worksheets a have merged cells, so in order to paste new data I need to unmerge them first. Below is the code that I wrote for it. However it doesn’t work and returns “Run-time error '1004': Application-defined or object-defined error”. I looked at this post List Maximum Value From Each Worksheet and tried adding With – End With, but it failed too. As far as I understood the problem is that the Worksheets/Sheets object does not support UnMerge property, but I may be wrong. If I add ws.Activate line (test2) everything works fine.

However I was wondering if there is a way to do it WITHOUT activating the worksheets.

Sub test1()
Dim i As Integer, ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
Select Case ws.Name
Case "5 - Top Network Facilities", _
"5b - Top Arb Facilities"
For i = 0 To 9
ws.Range(Cells(2 + i * 5, 1), _
Cells(6 + i * 5, 1)).UnMerge
Next i
Case Else
End Select
Next ws
End Sub

View 4 Replies View Related

Lookup Range Of Cells And Populate Specific Cells Based On Matching Data?

May 23, 2014

I am trying to build a staff roster. The staff rotate over a 4 week cycle. the name of the staff member, and their shift needs to be looked up from the key then matched with the particular week. the name and shift then need to populate specific cells.

I have attached the worksheet so you can see what i am trying to achieve.

View 2 Replies View Related

Excel 2010 :: Color Fill A Range Of Cells If Specific Cells Not Blank

Feb 7, 2013

I am using Excel 2010 and basically i am trying to fill a range of cell with a green color if any value was enter in a specific cells. Example: I would like to fill range: A10:c13 with a green color (regardless of the cells content in this range) if a value was entered in cell C10 or C11 or C12 or C13.

I've tried conditional formatting but unfortunately I'll have to apply formatting for every cell and for a range of over hundred cells is not efficient.

View 7 Replies View Related

Forcing Cells To ALWAYS Find MIN And MAXIMUM Values From A Specific Range Of Cells

Feb 1, 2010

I'm working on a project for my company. We make plastic tanks and for quality control we want to start recording the thickness of the tanks in different areas/zones of each tank.

Attached to this message is an Excel sheet that I've been working on. From "Sheet 1", it records inputted thicknesses into WorkSheet "1098". On the top of "1098", it shows all of the recordings, and just below that are the "10 Most Recent Entries".

Right below the "10 Most Recent Entries", there are formulas to calculate the Min and Max Values. Whenever a new entry is recorded, the selected cells for the Min and Max formulas change. Is there a way to force the cells to always stay the same?

View 3 Replies View Related

Code To Delete Cells Without Fill Color

Jan 25, 2013

I am looking for code that would delete all columns in a worksheet that do not contain a fill color.

View 9 Replies View Related

VBA Code To Delete Cells If No Data In Cell To Right

Aug 11, 2013

One more thing and I think I completed my project. I have a tab called comments.

Column A and B will always have data in them from 1-320.
Column C may or may not have data in it from 1-320.

Is there a code I could tie a button with that will delete the cells A and B if C has no data but leave it alone if C has data?

Ex: [URL] ........

When I click sort, only A1, B1, C1 and A5, B5 and C5 will still be there and everything else deleted.

View 5 Replies View Related

Excel VBA Code To Select A Range (rows) Based On Values And Delete

Aug 8, 2013

I am trying out with a code which checks for cell value as "Select" in column IU and then checks for corresponding column IV for value as "0". Please note that "Select" and "0" are populated by formulas. I need the select "Select" and "0" till the next "Select" occurs in column IU and delete the selected range and continue the process until last non empty cell based on column C.

I have written the below code but it doesn't work.

Code:
Public Sub Test()
Dim nRow As Long
Dim nStart As Long

[Code]....

I could have uploaded the excel file that I am working on but did not find any upload attachment option.

View 1 Replies View Related

Code Runs When I Hide Rows Or Delete Cells

Aug 2, 2008

So i don't have any events that i know of that should trigger my macros to run. But everytime i delete a cell, or hide rows, it seems all my code/macros just auto run. And i had a few times when i hid the rows, the code would start, and then my excel application would crash.

View 4 Replies View Related

Formula Or Code To Delete Cells If No Text Entered Inside Them

Jul 29, 2013

I am making a buiness card request form, which I have attached. On the Master Sheet (Sheet 1), the user enters in his/her personal data, such as his name address, phone number, etc. After he/she finished entering all the relevant data, Business Card Layout (Sheet 2) automatically populates and shows the user what their business card will look like.

Everything works fine, however I just realized that the contact information might vary from person to person. Right now, a person can enter 5 different contact information, but most of them will probably only choose four.

I wanted to know how to shift the cells down if the user does not fill out one of the contact information.

View 2 Replies View Related

Adding Cells Over Specific Range?

Sep 19, 2013

I'm looking to easily drag the sum of certain cells in a different column BUT keeping a specific range, it's hard to explain so i'll show an example...

A1
A2
A3
A4
A5
A6
A7
A8
B1=SUM(A1:A4)
B2=SUM(A4:A7)
B3=SUM(A8:A11)

And so on...

Is there any way I can do this by dragging down the cell formula from B1 and it remembering the range of 4, so I don't have to manually select each range...?

View 1 Replies View Related

Recalculate Cells In Specific Range

Feb 13, 2008

I have found the following piece of code which does almost what I want it to:

sub my_calc
range("A1:A25").calculate
end sub
However, the Range I want Excel to recalculate is, from the Active Cell, 20 Rows down and 81 Colums across.

How would this Range be defined in VBA, please?

View 9 Replies View Related

Search For Specific Characters In A Range Of Cells

Oct 5, 2008

I have a column of values of peoples initials and I want to cound how many times one persons initials occur in those cells. I can do this if the cells just contain one person i.e. "CH" or "DH" but if the cell has two or more peoples initials i.e. "CD DH" I can't do it as it only matches the exact search criteria.

How can I total the numebr of times a required set of initials appears in a specific column of cells? Not bothered is it requires a macro or a formulae, just can't seem to figure this one out.

View 9 Replies View Related

Excel 2010 :: VBA Code To Search Multiple Columns And Delete Any Duplicate Cells (not Rows)

Jun 12, 2014

My Excel program (Excel 2010) currently has several columns and each column looks for and pulls data from a specific file on my computer. Then I need to delete any duplicate data entries, count the number of unique entries and track the changes through a chart. I have everything done except I cannot figure out (or find on the internet) a way to search in multiple columns (more than 2) and delete just the duplicate cells. I want to delete the cells in a way where there is one left. For example if the code 12gf is duplicated three time, I want to be left with one 12gf (it doesnt matter what column the original one is left in). Additionally, column length changes and they are not sorted. I have attempted to attach an image of an example file below.

View 14 Replies View Related







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