Expand Selected Range

Nov 15, 2009

I need help please. Using a macro, I have selected the range C7:C12. Now I need to keep this selection and expand it 18 columns to the right. This would give me a selection of C7:U12.

The original range changes at various times. Some times it might be C7: C452 etc.

I know it's easy, but I can get the code to keep the selection.

View 6 Replies


ADVERTISEMENT

Expand Named Range

Jun 11, 2007

I am trying to dynamically manage a named range. As a new column is inserted to the right of the named range, the named range is then expanded/extended by one column to the right.

View 4 Replies View Related

Expand Range In Macro

Oct 16, 2007

I have a named range. The range includes a block of cells plus one extra row and one extra column. That is so I can insert a new row or a new column and still have them within the range. The last row and column are simply blank. I am trying to figure out how to select the part of the range that excludes the extra row and column, so I can then do a fill-right and fill-left. It seems like this should not be hard but I am getting all gummed up in the syntax. The last line of the following code excerpt produces a run-time error 13 Type mismatch. It compiles, however. (I have omitted some extraneous lines that have no effect on r or rf.)

Dim r As Range
Dim rf As Range
Set rf = Range("TotalFTEByStaff")
Set r = Range(rf.Cells(1, 1), rf.Cells(rf.Rows.Count - 1, rf.Columns - 1))

View 5 Replies View Related

Expand Active Cell To A Given Range

Aug 20, 2006

When i click commandbutton1:

Copy Active cell (columnB), next cell (ColumnC), next cell (ColumnI), next cell (ColumnO) all of which exist in the same row.

I will then paste the values into another sheet in the next available row which i think i have mastered. the cells will be pasted next to each other i.e. instead of column B,C,I,O they will be pasted as column A,B,C,D.

My dilema is i am not sure if you can use multiple cell offsets to perform this or if it is better to use a loop.

View 4 Replies View Related

Expand Active Cell To New Range

Dec 27, 2006

I have some working code that makes a number of changes to an excel report using VBA. Each time I execute the code I am taken to a different point in the excel report (depending on user inputs). What I now need to do is to change the cell selection from a single cell to three cells.

For example, my code may result in cell B100 being the active cell. What I now want to do is change the selection from B100 to the range B100:B103. I would have thought I could write something simple like:

Sheets("Group").Range("ActiveCell:Offset(0, 2)").Select

I have tried every variation of the above but I can't seem to make it run. Where am I going wrong?

View 2 Replies View Related

Dynamically Expand Range To Create Chart

Jan 21, 2009

See the attached example. I have data listed as shown, but need the chart to automatically update whenever a new sales figure is added to the next month. I know you have to use the OFFSET to create dynamic ranges but I can't get it to work horizontally, only if my data is laid out vertically.

View 2 Replies View Related

Expand Range To Include Non-contiguous Column?

Apr 1, 2014

How to make the below selected range, which represents column Q, also include column A?

Range(ActiveCell, ActiveCell.End(xlDown)).Select

View 4 Replies View Related

Expand Named Range Based On Cell Value

Jun 13, 2008

I have a workbook containing two worksheets - Sheet 1 being my "data entry sheet" and Sheet 2 is a sort of summary report containing multiple named ranges (all grouped according to similar values in a cell i.e. all cells containing 1-1 is named GRP1, all cells containig 1-2 is named GRP2). Basically, my workbook looks like this:

Sheet 1
A B C D
1 Lea Female 1-1 Lea Wells
2 Leo Male 1-2 Leo Anderson

Sheet 2
A B C D
1 Anne Thomas Female 1-1
2 John Doe Male 1-1

4 Jimmy Beads Male 1-2
5 Mary Fox Female 1-2

Hence, when I enter the data as shown in Sheet 1, Sheet 2 should look like this:

A B C D
1 Anne Thomas Female 1-1
2 John Doe Male 1-1
3 Lea Wells Female 1-1

4 Jimmy Beads Male 1-2
5 Mary Fox Female 1-2
6 Leo Anderson Male 1-2

View 4 Replies View Related

Pivot Table - Automatically Expand Range Selection Of Data

Oct 12, 2002

Possible to get a pivot table to automatically expand the range selection of data as it grows. I have a worksheet that grows daily and I am running a pivot table from this. If I refresh the pivot table it doesn't pick up new data unless i change the range or i have a huge range selected in the first place. Problem is if i select a huge range then the grouping options i am using won't work correctly.

View 5 Replies View Related

Excel 2010 :: Expand Text Number Range Into Separate Cells

Feb 20, 2014

Using Excel 2010.

I have data in excel which looks like this:

Column 1 has 1200-1209,1300-1350,1523-1563
Column 2 has 1400-1409,1600-1650,1823-1863

I would like to take the range of e.g. 1200-1209 and have excel put 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 into separate adjacent cells for me. And be able to do this for each column/cell of data I have like this.

Column 1 1200
Column 2 1201
Column 3 1202

Like that only. Is it possible?How?

View 4 Replies View Related

Fill Range Of Cells With Text When Listbox Option Selected - Clear When Not Selected

Jul 25, 2014

I am using this code to hide or unhide rows of text on another sheet:

VB:
Sub ProcessSheet1ChangeOnCellJ7(ByVal Target As Range)

Dim sAddress As String
Dim sValue As String

'Get the address of the cell that changed without '$' signs
sAddress = Target.Address(False, False)

[Code]....

When the "Not Pursuing" list box option is selected (in cell "J7" or "J8" in Sheet 1) I need to add (or over-write) "Not Pursuing" to the range of cells in column "B" (in the "Tasks" sheet), but only for that particular Goal, meaning a limited range of cells in column "B". If the "Pursuing - Show All Tasks" option is selected for a Goal then these same cells need to be blank so that the appropriate person can enter their name into the cell.

The purpose for adding "Not Pursuing" automatically to these yellow highlighted cells is that it will facilitate filtering of tasks by individual in the "Tasks" sheet..

Again I have tried several times to upload a sample file and am unable to, which I know makes it more difficult to solve. (Is there some common mistake people make? I know it's an allowed format and is very small in file size....)

Code solution can be entered directly beneath:

VB:
If Target.Value = "Not Pursuing" Then
ActiveWorkbook.Sheets("Tasks").Rows("29:29").EntireRow.Hidden = False
ActiveWorkbook.Sheets("Tasks").Rows("30:48").EntireRow.Hidden = True

View 1 Replies View Related

Set Range From Selected Cells/Range

Sep 16, 2009

I have a macro which I manually have to change the range in order to run the macro, e.g. Set rngData = Range("B4:I12")

rather than having to change the range for each macro, I was wondering if I could run the macro for the highlighted area. I have tried this, but doesn't seem to work.

Set rngData = Range. CurrentRegion.Select

View 2 Replies View Related

Calculate Only Selected Range

Oct 5, 2009

I'm currently on Manual Calculation mode. I have formulas in cells A1 to A10 which has not been refreshed. Can I select only range A3 to A6 and recalculate only those cells?

View 5 Replies View Related

Inserting Range Above Selected Row

Mar 8, 2012

I have a range (of 2 rows) that are set up as a header row and sub row. I want a macro to insert these above the active row (ie. where the user places the cursor), but when I select and copy the range in the macro, I don't know how to refer back to the 'active row' because that's not active anymore.

I'd also like the cursor then to be placed into one of the cells in the new row, ready for the user to start editing.

View 6 Replies View Related

Looping Through Selected Range

Jul 2, 2013

I am looping through a selected range. The code searches through column B and finds any data. If found, it returns the value to a different workbook to column B. When there is no more data, it goes to column C and does the same thing. My problem is, when there is no data in a column it returns a blank. How do i get rid of this blank???

View 1 Replies View Related

Count & Sum Of The Selected Range

Mar 16, 2007

Count & Sum is one of the most usefull function in the Excel,
I always used this, Is it possible in VBA to create such code that if I Select a range and click on Commandbutton1 automatically one msgbox display with the Count & Sum of the Range Item

eg. If Range A2 to A5 has a number like 50,10,20,10

here if the command button is click automatically one msgbox is display
which showing the

-Total Sum of the Seletced Range is 100 and Total Count is 4

View 9 Replies View Related

If Statement With Selected Range

Aug 10, 2007

I'm trying to create an if statement that have 2 criterias. Here's what I've created:

=IF(COUNT(F2:F4)=('2007Open'!H2:H4),COUNT('2007Open'!B2:B4)=8,'2007Open'!H2:H4)

This statement is returning the #VALUE error.

I guess what I'm trying to do with this statement is to count how many values are not equal to 2007Open!H2:H4 and meets another criteria of 8.

View 9 Replies View Related

Autofill Using A Selected Range

Jan 4, 2008

I am using the following code to Autofill a formula through a variable range:

Selection.AutoFill Destination:=Range(MyFormulaCell, TerminalCell), Type:=xlFillDefault

MyFormulaCell is the cell with the formula, and TermnialCell is a variable set on a count of rows. This is working great, and I can loop through this for the columns I need to copy just fine by incrementing values, but as I apply this to several sections, it's taking me up to a minute to run the macro. In this "I want it now" day and age, I'm sure my coworkers for whom I am making this will not be happy to wait that long.

Is there a way that I can incorporate a selected range into this method?

I'd like to set MyFormulaCell to:
Range(Selection, Selection.End(xlToRight)).Select
and then autofill the formula down the number of rows contained in TerminalCell.

View 9 Replies View Related

User Selected Range

Dec 3, 2008

I have a form that asks at what row the user wants to start with a selected range then how many rows to select. There will always be 21 columns selected with this range. I am still learning but it has to do with something on how I am setting the Start object. It is not being recognized.

Dim Row As Long
Dim Selection As Long
Dim Start As Range

Row = txtStartRow
Selection = txtHowMany
Set Start = Range("A" & txtStartRow).Select

Range(Start & ActiveCell.Offset(Selection, 20)).Select

View 9 Replies View Related

Delete Selected Range

Mar 17, 2009

My data is in one column as follows:
ABC
(BLANK)DEF (BLANK)(BLANK)
What I want to do is to delete the blank cells and count how many not-empty cells.

The following sub works fine if I put the active cell manually in A1. However, the first range select always give me the "1004" error. Why? I don't have any clue.

Range("a1:a5").Select
Do Until ActiveCell.Value = "stop"
Do Until IsEmpty(ActiveCell)

Selection.Offset(1, 0).Select
Loop
ActiveCell.Delete
Loop

View 9 Replies View Related

Chart Selected Range

Nov 29, 2006

I am trying to link data that has been entered into a inputbox with a range of cells.

My goal is to allow the user to answer: how many people sat the exam?

Therefore when a chart is automatically produced only the cells with the required data are selected.

So, my range is A2:C*

* being the user input.

View 4 Replies View Related

Naming A Selected Range

Mar 15, 2007

I am trying to name a selected range in VBA in order to use it in a vlookup table. Code I have so far is as follows:

ActiveSheet.Name = TextN
Range("c9"). CurrentRegion.Select
Call formatting
ActiveWorkbook.Names.Add Name = "formTextN", RefersToR1C1 = Worksheets(TextN) & "!" & "r9c2:r45c13"

The formatting works, but the selection does not get named.

View 3 Replies View Related

VBA ListBox - If Range Is Equal To One Of The Selected

Dec 19, 2012

I have a spreadsheet with names of students, year groups, subjects and others. My VBA code will analyse student's results, but before I get there I would like the user to be able to select groups of students using listboxes.

Now I have a tonne of variables that I won't bore you with but the main thing I would like to do is to scan through each cell in a range on my spreadsheet and determine if the value of that cell is equal to a selected option in the listbox. This will let me, for example, filter by only Year 10 students, or select to display only Year 9 and 11 students.

I already have the code to scan through each cell:

VB:
'Run through each student and check they match the criteria
For N = 1 To StudentList.ListCount

'Split the first and second names
StudentName = Split(StudentList.List(N - 1))

[Code] .....

Essentially, I would like to take the cell "A" & N2 and check to see if it matches one of the selected options in a listbox called "YearList"

View 1 Replies View Related

Highlight Range Of Row Then Cell Selected

Apr 2, 2014

i have data in range c10:h100

i want if select a cell e.g = c15 then

highlight the range c10:c100 with color

now highlight the all row only highlight defined range

View 5 Replies View Related

Applying Macro To Selected Range

Apr 3, 2014

I have a macro which sorts data within a cell. This is working perfectly fine but the only problem with this is that it works only for a single which is selected. How can I apply this macro to range of cells I select using a mouse.

View 3 Replies View Related

Calculating Percentiles Of A Selected Range

Apr 12, 2014

What I need is the following: I select a range of numbers and for this range I want to calculate the 1/3th and 2/3th percentile, and these should come in two cells that I can easily change in the vba code.

Some formula in which I can give two inputs: first the range of which it has to calculate the 1/3th and 2/3th percentile and a second input which is just a number and than the vba should say whether that second input is in the first range (between 0 and the 1/3th percentile value) or in the second range (between 1/3th and 2/3th percentile values) or third range (between2/3th percentile value and highest value).

View 1 Replies View Related

Removing Column(s) From Selected Range?

May 8, 2014

I have the following code that selects a range based on the rows that have data in the sheet, starting with row 10:

[Code]....

This works well, but by default it captures all columns with data. I'm not sure how to then change it to only capture specific columns.

For example, if I only wanted columns B:D for rows with data, changing it to

[Code] .....

does not work, because the SpecialCells selection overrides that and still returns all columns with data.

Is there an easy way to drop column(s) off of the currently selected range after SpecialCells captures the range?

View 1 Replies View Related

Define Range By Selected Cells

Jul 19, 2014

I am working on some code to copy data from one sheet to another, but I'm not sure if I'm going about defining the copy range correctly. I would like it so that the user can highlight a range of cells on the sheet between A3 and F last row (last row based on col C). However the user should be able to highlight rows in any column between A and F, and they could highly the records with just one column or multiple columns. It should take the row numbers of the highlighted range and use the that as the row number to extract the data from.

[Code] ........

Im currently getting runtime error 13 on 'CopyRange = Selection.Rows'

'CopyRange = Selection.Row' returns the single row number for the first cell in the selection, but i need the range of all the rows in the selection.

View 6 Replies View Related

Selected Cell Within Named Range?

Dec 23, 2008

I want to use the Worksheet SelectionChange event to update part of my worksheet/UI depending on what cell(s) the user has selected.

As an example, if I have two named ranges - $A$1:$B$10 and $C$1:$D$10 - I want to detect whether the user is in range 1, range 2, or neither, then update elements of the UI.

View 4 Replies View Related

Changing Range Selected With Variable

Jan 17, 2009

I have some code that uses offset to select a column of numbers

View 2 Replies View Related







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