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
ADVERTISEMENT
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
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
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
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
View Related
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
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
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
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
Nov 24, 2006
I'm looking for a piece of code, which would activate a certain Range i.e. the start of which would be in column A and the End in Column G. My problem is that the activated range of cells shuld be exactly in the same row as the currently active cell i.e. active cell B3 -> activated range A3:G3 .
View 6 Replies
View Related
Jan 10, 2007
I Have searched existing threads but cannot find the answer to my query,
As part of a longer macro, I want to sum all cells in a column which contains data. Each day the number of cells that contain data will vary.
I have tired specifying all the cells in the column which contain data as a range, by selecting the top cell and using the
Range(Selection, Selection, Selection.End(x1Down))
But I cannot get a SUM Formula of this range. If someone could show me the correct syntax to get a sum from a range like this I would be very grateful.
View 6 Replies
View Related
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
Jul 2, 2014
I have a form that loads and depending on the word selected in the drop down the following code loops through cells Q2:AC2 until it finds the word in one of those cells (the word will always be in one of the cells)
Code:
For Each c In Range("Q2:AC2").Cells
If c = period Then
c.Select
[Code]...
The active cell it finds will always change, i know I need something to code the active cell back but I don't know what it should be.
View 5 Replies
View Related
Jan 27, 2009
How can I define a range, only for the active cell?
View 6 Replies
View Related
Feb 11, 2009
I have this code I wrote (combining variations of existing ones).. but not very well. unfortunately doesn’t seem to work. It copies the information back onto itself
View 5 Replies
View Related
Jul 16, 2009
I would like to start off in col A, do an offset until a certain value is reached:
View 2 Replies
View Related
Sep 27, 2009
how can I resize a from my active cell to a specific cell (eg. L1) and select all the cells in between? I am using this code to select the last cell after my data (active cell is in column A).
View 2 Replies
View Related
Oct 15, 2012
I am after a vba code that will sum the range from the activecell upwards.
The range does not go to the top of the column there are many blanks cells therefore it would need to
Range(Selection, Selection.End(xlUp)).Select
This is what I was working on and isn't very good and the sum formula does not work even though I have change the formula many times.
Code:
Sub Macro1()
Dim cellC As Range, rng As Range, topcell As Range, bottomcell As Range
Set bottomcell = ActiveCell.Offset(-1, 0)
Dim s1 As String
[Code] ..
View 4 Replies
View Related
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
Jun 18, 2014
So the constraints are
1. if there's a value in name or names count => must be at least one value in test1 or test2
2. last value in names count must be equal to the sum of trues in B1:B4 Problem Is it possible to identify once any of the cells in A9:D12 are activated that once that range is deactivated I run the check to make sure the constraints are met, and populate default values in the case they are not?
Is it possible to identify once any of the cells in A9:D12 are activated that once that range is deactivated I run the check to make sure the constraints are met, and populate default values in the case they are not?
Trying to figure it out with a some combination of: checking if the last cell I was in was in the range and I am no longer in that range; using the selection change change event?
[Code]....
Attached File : HelpMeWorkbook.xlsx‎
View 8 Replies
View Related
Oct 21, 2009
I want my code to evaluate each cell in column B, and based on its value, copy the row from D to X and paste on the newly activated worksheet. I'm trying to use Offset, but it's not working.
View 6 Replies
View Related
Apr 17, 2009
Split from: Clear Range To Right Of Active Cell Down. I was working through this the first step was to clear the contents of the cells. After they are cleared, I have another sub that then goes and retreives a unquie number and places it back at the top of the column that I just cleared. Would this same code that cleared the cells contents work to copy the contents of the active cell down that same column, until the cell to its right is blank? -R-
View 5 Replies
View Related
Jul 27, 2007
I am working on a macros that creates a new row for every data entry. Below is the macros that I have. In the new row, I want for the cells in columns F through O to merge right after creating the row. How do I go about this?
If Sigma = 0 Then
Selection.EntireRow.Insert ' New row for new entries
ActiveCell.Value = "NONE"
ActiveCell.Offset(1, 0).Select
End If
View 4 Replies
View Related
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
Feb 24, 2012
I'd like to ranage the range selection from D1 to A1:B53, but a number of attempts have failed. but can't get it working.
Code:
FileName = "R" + Scheme + Product + "_" + Format((Date + 1), "DDMMYY") + ".RP3.txt"
Sheets("RP3").Select
Range("D1").Select
WholeText = ActiveCell.Value
Call OutPutFile(WholeText, FileName)
View 1 Replies
View Related
Oct 27, 2009
I'm trying to select a range of cells whereby the range is dependent on the currently active cell. I know you can use the "Activesheet.Range("A1:D2").select" method to select a range where the cells are always the same, but I'm after a dynamic selection where the values can be programmatically altered depending on some other result.
For example, let's say that I make a certain cell active (based on the result of some other formula), and I want to select the range of cells in the adjacent column that is X rows deep. Putting this into context, imagine the resultant active cell is B2, I then want to select the range C2:C10, but if the active cell is E10, the range selected would be F10:F18 (if active cell is X, then range would be Y:Z).
The Offset function would allow me to position the cell based on the current active one, but it doesn't let me select a range. The Range function only lets you choose either hard coded or index cells, e.g. "Range(cells(y,z), cells(y,z)).select", but this is still no good because I'd need to know the index value of the active cell (can this be done?).
View 4 Replies
View Related
Dec 6, 2009
can someone make a code for a range.Name = "match" as soon as active then that active cell is to be copied to cell C2.
View 9 Replies
View Related
Mar 23, 2009
I RECORDED THIS MACRO BUT I WILL LIKE TO MAKE TO AUTO SELECT THE ACTIVE CELL RANGE IS VARIABLE ON MY REPORTS MY CODE
Sub FORMAT_AS_A_TABLE()
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$L$1900"), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleDark5"
End Sub
View 3 Replies
View Related
Jul 15, 2014
How can I convert all cell values in active range to text format without losing the actual value.
For Ex.
0123 will remain 0123
07/12/2014 will remain 07/1/2014
3453 will remain 3453
regardless of there previous format. Currently I am doing this manually for every column before creating a load file for SQL database.
View 7 Replies
View Related
Feb 22, 2009
The rows will differ depending on the Active Cell that's selected and I don't know how to specify this.
The range I want to copy is from Column B to DA on the worksheet ("Staff") which I want to paste to another worksheet ("Leavers"). This is as far as I got
'FindRemove = lstRemove.Value
'If FindRemove = "" Then End
' Goes to the start of the Data column
'Sheets("Staff").Select
'Range("B4").Select
' Tests current cell against FindRemove
'Do
'If ActiveCell.Value = FindRemove Then
'Call CopyPerson
'Exit Sub
'Else: ActiveCell.Offset(1, 0).Select
'End If
'Loop Until ActiveCell.Value = ""
'End Sub
View 9 Replies
View Related