Clear Named Range & Columns To Right

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


ADVERTISEMENT

Clear Contents Of Named Range In 2007

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

On Cell Selection, In Named Range, Clear Content Or Add Text If Empty

Jul 24, 2009

I wrote some code that toggles bewtweeen the word "Yes" and the function clearcontents.

What it does not do, is if you click on cell A1 and change it's contents and you click on the same cell again it does nothing. You need to click on another cell say A2 before you can go and change A1 again.

My code is as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub

If Not Intersect(Target, Range("Documents")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Value = "Yes"
Else
Target.ClearContents
End If
Application.EnableEvents = True
On Error Goto 0
End If

End Sub

View 3 Replies View Related

Clear Old Data And Add New Data Every Month, The Named Range Changes

Dec 13, 2008

I have 30 worksheets in a workbook in which the first sheet is called summary. The summary sheet has 29 formulas with all named ranges, so one named ranged per worksheet. The issue I have is when i clear old data and add new data every month, the named range changes on some worksheets not pointing to the correct range as previous month file even if I have $

View 9 Replies View Related

Named Range -- Different Columns

Jan 28, 2009

I have a countif formula on another tab collecting data from these cells. I want to define a combined name DecBestFL with cells A1:A14 and G1:G14. Can I do that in Excel 2007?

On the other tab I would use =countif(DecBestFL,G5) G5 = "Y"

View 9 Replies View Related

Count Columns In Named Range

Nov 22, 2006

Anyone know code to count columns in a named range? Got some code that i want to utilize for multiple things so i cant hard code the column count in anymore.

Dim intColumnCount As Integer
Dim X As Integer

x=0

Range("Poo").select
intColumnCount = magic voodoo code

For Each cell In range("Poo")
x = X+1
If ((x / inColumncont) > 2) And ((x / intColumnCount) <= 3) Then 'if on actual row
If IsDate(Cell) Then ' if there is a date in actual
Cell.Interior.ColorIndex = 15 ' shade actual gray
Cell.Offset(-1, 0).Interior.ColorIndex = 15 ' shade prom gray
Cell.Offset(-2, 0).Interior.ColorIndex = 15 ' shade Sched gray
End If
End If
If x = (intColumnCount*3) Then 'went thru Sched, Prom, & Actual
x = 0 ' Reset x
End If
Next

left off a bunch more if statements that formats other stuff but u get the idea... Need Magic Voodoo code replaced with working code

View 3 Replies View Related

Hide Columns Within Named Range

Apr 29, 2008

I am trying to hide columns within a named range, where the range corresponds with the values section of a pivot table.

My code hides an unexpected set of columns. It seems to be affecting a different range, depending on the number of columns in the pivot table, which is not part of the named range, as if there was some kind of offset.

Sub hideAll()

With ActiveSheet.Range("wholeyear")
.Range(.Columns(1), .Columns(12)).Hidden = True
End With

End Sub

View 5 Replies View Related

How To Use Named Ranges In VBA Code Using Columns And Variation On Range

Mar 17, 2014

I am trying to clean up my code by using named ranges so that it will still work if/when others add columns or rows to the spreadsheet. These should be pretty easy solutions for most of you but I can't seem to find any answers online.

Here are 2 examples of the code I am trying to update:

I was thinking that replacing "A" with "namedRange" would work but I suppose that's not how the Columns application works. How can I modify the code below to work with a named range instead of the fixed column "A"?

[Code].....

For the following I would have thought that replacing "AU" with "namedRange" would do the trick as that's how things have worked for me in the past using the Range application. Unfortunately I get an error when I make the change.

[Code] .....

View 2 Replies View Related

Use A Named Range To Many Columns Are Added Or Deleted The Data Is Pulled Correctly

May 4, 2006

I have a spread sheet that I pull data from different columns on a particular row. The problem is the code I used works great as long as the column never moves from its current location. Is there a way to use a named range to make the following piece of code work, so no matter how many columns are added or deleted the data is pulled correctly?

View 2 Replies View Related

Clear Named Ranges

Jan 5, 2009

There are over 100 named ranges in my excel 2007 workbook. Is there an easy way to clear all of these out?

View 9 Replies View Related

Determining If Cell Is Part Of Named Range And What That Named Range Is?

Aug 16, 2014

Let's say you have a named range, Rng1, which consists of cells A1 & A2. In vba how would you report back what, if any, named range the following cells resides:

Code] .....

here are multiple named ranges so using intersect is not feasible. Essentially, through code, I will be given a range and I need to determine if that range if part of a named range.

View 5 Replies View Related

Named Ranges On Multiple Sheets With The Same Named Range & I Cant Figure Out How To Do This

Jun 2, 2006

I need to create a named range on multiple sheets with the same named range & i cant figure out how to do this. EG :- I want to create a named range called "_SubUnitRows" on sheet1 starting from "A1:A50" & other named range again called "_SubUnitRows" on Sheet2 starting from "A1:A25" ...

View 2 Replies View Related

Making Named Range The Last Active Value Used Within Another Named Range?

Jul 19, 2013

I'm trying to make my named ranges remember the values of the last active cells used within another named range. The purpose of this is to make my charts dynamically change dependant on two criteria selected. My spreadsheet currently updates itself as and when I change the active cell within a single named range, dynamically changing the chart data by using Lookup based on the active cells value. However I want to get away from having several charts showing, I would like to have a single chart which dynamically changes based on a second selection. So the first selection is for a department (Facility) which changes the chart data relevant to that department, the second selection is to dynamically change the chart shown for the pre selected department.

Picture2.jpg

Using the following code when updating just one criteria with several charts

VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(ActiveCell, [MeasureType]) Is Nothing Then
[valMeasurePicked] = ActiveCell.Value [code].....

which works fine but I'm not sure how to add a second selection criteria because my code uses Activecell. I thought that the VBA needed to set the last used value of a range as a variable and therefore allow the second criteria to be selected but am not sure how to put it into practice.

View 2 Replies View Related

Countif- Use A Named Criteria As Well As A Named Range

Oct 25, 2009

if I can use a named criteria as well as a named range. In essence what I am looking to do is count certain cells that meet the criteria in a certain named named range,

View 9 Replies View Related

Combine Two Named Ranges Into 3rd Named Range

Mar 14, 2013

Merge two columns into one list in excel

I would like to combine List1 and List2 into a 3rd named range called List3. I was wondering if this were possible without using any additional cells/columns (i.e. I don't want to use Column C like in the example shown in the link above).

Here's the formula from the example:

Code:

=IFERROR(INDEX(List1,ROWS(C1:$C$1)),IFERROR(INDEX(List2,ROWS(C1:$C$1)-ROWS(List1)),""))

I've played around with it, but could not come with any that worked.

View 3 Replies View Related

Clear Columns In A Row?

Jun 16, 2014

I'm trying to clear the data on columns Q thru AE on which ever row I am on.

View 3 Replies View Related

Macro To Clear Zero's In Columns

Jul 21, 2007

I need a macro that will clear out all zero's in columns D8:O?

The amount of rows vary, but should never exceed 1000. I'am not wanting any cells to shift. Just the contents deleted.

In other words, if e5 contains the value 0, I need it to not contain anything.

The exception is the total row.see file for example.

View 7 Replies View Related

Copy/Paste Cell To Named Range Named In Adjacent Cell

Sep 4, 2007

I have read post re this question but have not been able to answer my problem. I get the error message 'Application defined or object defined error' when running the code below. I should indicate the range counter currently indicated about 6,200 rows that this code will work on and the individual range names in the list of 6,200 rows are spread over at least 20 worksheets.

The code appears to be running but after some time it stops on the line of code 'Range(Cells(i, 1).Value) = Cells(i, 2)'.

Sub PopulateWithImportData()
Dim counter As Integer
counter = Sheets("Imported Data").Range("Counter")

Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual
Worksheets("imported data").Select
Range("a1").Select

i = 1
Do Until i = counter
Range(Cells(i, 1).Value) = Cells(i, 2)
i = i + 1
Loop

View 8 Replies View Related

Clear Two Columns And Keep Relative Address

Oct 21, 2008

A few days ago I had a list of values in column A, and wanted to display in column B, in the cell where the cursor is when the macro is started (let's call it Bn), the sum of values (An:An-11), where n can be any row where there are values to be added.

"XLD" showed me how to clear the values from the column where the cursor is when the macro is started, and how to display in that cell the sum of 12 values in the adjacent column.

View 11 Replies View Related

Macro To Clear Data In Specific Columns

Apr 19, 2013

I have set up a macro to clear data in COl A from row 2 onwards. I need to amend the code to clear the data in the following columns from row 2 as well

Col C to I and Col L to O

Sub ClearData()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
With Range("A" & i)
.ClearContents

End With
Next i
End Sub

View 4 Replies View Related

Clear Contents In Specific Cell And Cells In Next 2 Columns To Right?

Jul 3, 2014

I am currently using this Code to search column1 for a Key Word that is entered into textbox "Kunde" on my userform.

[Code] .....

What i would really like to be Abel to do is :

Search for the cell in column1 with =Kunde.Value

Clearcontents of this cell and the 2 adjacent to the right.

i.e. Word is found in A7

Cells A7:C7 contents are cleared and fill Color returned to default colorindex 0

View 3 Replies View Related

Code To Clear All Contents In Columns With Specific Text In Row 2

Jul 29, 2014

Below is my initial code that can't get past the first line.

if right(cells(2,i),4) = "D_MA" then ..... ?

I'm trying to clear the contents of all data in each column that has the text conaining "D_MA" in that columns row 2. For instance, if cell F2 has 30D_MA, I want the macro to clear all contents in Column "F" -- but to do this for all columns that contain "D_MA" in row 2.

View 8 Replies View Related

Hide Unwanted Columns & Clear Ranges Based On Cell Value

Sep 17, 2008

I have written a VBA procedure which is supposed to hide unneeded columns (based on the a number entered in a certain cell. This is working so far. Since I need to sum only the visible cells in a row i need to clear the contents of a range of cells if they will be hidden. Unfortunately the code i have written runs only to the ClearContents and then starts over from the beginning. If i take out the .clearcontents and put .Select for example instead, the code runs perfectly.
Here is the

Sub worksheet_calculate() 'Hide columns that are not needed

Sheet1. Unprotect

Application. ScreenUpdating = False

Dim i As Integer
Dim r As Integer
Dim s As Integer
Dim rngRange As Range

i = 2

View 8 Replies View Related

Find Matched Value In A Range For Named Cell Then Copy Range Cells Below

Aug 6, 2013

I need method, using a button, that looks at a cell--say EO2, for example--, looks back on a master worksheet at a specified row and range for a match, then looks at the information from a specified range below the matching cell (The information in this column will either be blank or have an "X" in the cell), and then those rows that do not have an "X" will be hidden in the corresponding rows in the working worksheet. Therefore, if at any time the value in "EO2" ever changes, then it will automatically find a new match and repopulate and hide information as before. About 130 columns will have its own button so that a "query" can be made that depends on the information in a particular cell in that column.

The master worksheet now has matrix of 287 rows and 58 columns. Each row is for an operating procedure and each column shows a job code. An "X" in a coordinate cell for a column/row shows whether that job code is responsible for knowing that operating procedure. So, on the working sheet, an employee's primary job code is given underneath his or her name. When the button is pushed, all the operating procedures not required for a given person will be hidden and only the required ones will remain visible--grouped, if you will. Qualification dates will be easier to see now that the information is consolidated. Whenever someone transfers to a new position, a new code will be inputed on the working sheet. When the button is pushed, a new grouping will result. Any operating instructions that overlap will still have qualification dates, so that information will not need to be transcribed.

View 9 Replies View Related

Dynamic Named Range Sort Including Cells Outside Defined Range

Apr 3, 2008

Im sorting a dynamic range as mentioned in this Sorting a Named Range. My range is called drWarningTypes and is defined as:

=OFFSET(DataSource!$A$2,0,0, COUNTA(DataSource!$A:$A)-1,1)

When there is only one cell in the range, then running the following sort function includes A1 also in the search (and also adjoining columns).....

View 9 Replies View Related

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

VBA To Get Average Of Range Of Cells Based On Named Range In Different Column

Apr 10, 2013

I am trying to calculate some averages. What I have is 3 columns of data in A, B, C, also the "tasks" in A are in named ranges ex: "Award Contract" is a named range - "Task_Award" and "Confirm Updates" is a named range - "Task_Updates". I've attached a sample excel sheet.

I'd like to be able to create a macro to evaluate column A, and for every row in range "Task_Award", give me the average of the corresponding cells in column C and put it in the same range of cells in column B , then, for every row in "Task_Confirm" then give me the average of the same range of cells in column C and place the result in the same range of cells in column B. This is my very first post so I hope I am doing this correctly. I have 77 of these task ranges to evaluate and it will take a long time to do it manually. I'm thinking of a loop function.

View 1 Replies View Related

Creating Named Range Taking Avg To Date Of Dynamic Range

Jul 15, 2014

I have a column of data that keeps getting new information in it. what i need is a named range that i can use for a chart, first point in the named range will be the first value in the column, second point will be avg. of point 1 and 2, then 3rd point will be avg. of 1,2,3 etc.

View 1 Replies View Related

Get The Range Address Of A Dynamically Named Range That Refers To A Formula In VBA

Aug 10, 2008

I have a named range that expands and contracts based upon the amount of data that is in some column. Call it AllData_UsedRange.

I have another named range that actually refers to a range. Call it AllData.

Column A
Row2 56
Row3 44
Row4 65

AllData is a named range that refers to the range A2:A65536
AllData_UsedRange refers to A2:A4 by way of this formula.
=OFFSET(AllData,0,0,COUNTA(AllData))

How to I obtain an address of AllData_UsedRange in VBA code?

These do not work...
ThisWorkbook.Names("AllData_UsedRange").RefersToRange.Address
Evaluate(ThisWorkbook.Names("AllData_UsedRange"))

View 9 Replies View Related

Stop Graph From Changing Named Range To Formula Range

Sep 8, 2006

I am trying to create a graph for a range of data that updates monthly (adding an extra month each time). I wanted the graph source data to update automatically each time the data is refreshed so used an OFFSET formula to identify a named range. I then point the graph to the named range as the source data.

When I enter the range as the source data the graph picks it up. However, when I re-enter the source data option on the graph it has converted the named range into a cell written range (ie. replaces "=QUALITY" with "='Front page'!$B$7:$J$10" - which therefore will not update when the range increases.

View 4 Replies View Related







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