Selecting A Range From Starting/ending Cell Rows And Columns
Feb 19, 2010
I need to accomplish selecting a range using variables for the starting cell and ending cell rows and columns.
Pseudo code (how I'd like the syntax to be, but isn't):
Worksheets(mysheet).range(startCellRow, startCellCol : endCellRow,endCellCol).Select
With Selection
...
End With
View 6 Replies
ADVERTISEMENT
Jul 4, 2009
I am using Excel to use stock ticker symbols such as FDX "Fedex", to return past volume and price daily performance found in Google Finance that will be manipulated with the current VBA I am working on that will result in a trading pattern. Each trading pattern will happen at a different range in the same column. I will be inputting hundreds of ticker symbols daily so using VBA and not having to enter formulas manually in each is greatly preferred as this will save me lots of time.
I am stuck trying to find the average value of a range starting from the minimum to the maximum value. For instance, Range("H10:H20") may have a maximum value at range("H12") and a minimum at Range("H18"). I would like the average of Range("H12:H18").
Sub Fnd()
Dim MaxStartPriceRange As Range
Dim MinStartPriceRange As Range
Dim MaxPriLocation As Double
Set MaxStartPriceRange = Range("h11:h21")
MaxPriLocation = Application.Max(MaxStartPriceRange)
Set MaxStartPriceRange = MaxStartPriceRange.Find(MaxPriLocation)
Dim MnPriLocation As Double
View 4 Replies
View Related
May 13, 2013
I'm trying to develop a new daily timesheet for my production workers, where non-production items are recorded in 15 minute intervals. The user would put in "Clock in" by the corresponding time, and the same for "Clock out" at the end of the day. Any non-production items will be type in next to their appropriate time. Since clock in and clock out times will vary, I need to set up a formula that searches the array of cells for the day, finds the "Clock in" and "Clock out" values, and counts any blank cells in between them. Basically the blank cells will equal production time, and the result of the Count function will be multiplied by 0.25 to get the hours.
I am having a very difficult time finding a way to set the "Clock in" and "Clock out" cells as the range for the Count function, because it won't always be the same cells. What would be the best way to automatically have excel find the cells containing these values and set them as the range criteria for a Count function?
The formula at the bottom was one of my initial attempts, but it didn't work. I took out the '=' for the screenshot, so that wasn't the problem.
View 5 Replies
View Related
Jul 21, 2014
I want to fill an array from values in range A1:H10. I want to fill the array with all rows in range and only columns B,C and E. I have the code below so far using index function.
Is there a more direct way to select all rows from desired range to avoid the need to create an array of rows from 1 to LastRow and then use Application.Transpose(RowsArr) (in red) inside Index()?
View 3 Replies
View Related
Jul 10, 2014
Is there a way to display just the staring and ending labels in a line graph.
I have around multiple line items, each contiaining 15-20 data points.
When I instert line graph with data labels, it becomes very mesy.
So I want to display just the starting and ending number of each line graph.
Manually selecting the data point and adding labels is very time consuming as I have around 200 line graphs, each containing 7-8 data series.
View 3 Replies
View Related
Aug 26, 2013
I have a macro that copies three sections of data from a word document and pastes it within the Excel worksheet. The column of data is pasted in a single column (data to be space-delimited and evaluated later), and what I would like the MACRO to do is separate the three sections of data based on the starting and ending values of the section and place them in different columns.
Section 1 : starts with the word "Team"
Section 1 : ends with the word "City"
Section 2 : starts with the word "Location"
Section 2 : ends with the word " Date"
Section 3 : starts with the word "Member"
Section 3: ends with the word "Age"
So section 1 would be pasted into cell C1, section 2 pasted into G1 and section 3 pasted into J1.
Each section will have vary in number of rows between the starting/ending values, so to cut and paste the section based on the starting and ending value is vital.
View 7 Replies
View Related
Feb 10, 2010
I have a code that print previews a certain amount of rows that I define. This basically says print preview the first 10 lines down.
Can the code be modified so that i can select a start cell. So instead of always starting at A1 I could select say start at G1?
View 14 Replies
View Related
Apr 30, 2008
Continuing with a large Macro I am trying to peice together, I have reached a hurdle where I need to hide all columns to the left of the ActiveCell (which varies week to week) back to column B.
I have the following code which selects the correct number of cells to the left of the active cell but doesn't highlight the whole columns - just 3 cells for each column (very odd)
ActiveCell.Offset(0, -1).Range("A1").Select
Range(Selection, "B" & Selection.Column).Select
I'm sure it must be something to do with the
Selection.Column
part as when I write
Selection.Row
it just does 1 cell for each column (as to be expected)
I should mention I already have the coding to hide the columns, just need a way to highlight the relevant ones.
View 3 Replies
View Related
Jul 4, 2007
I found dynamic range name across columns:
=OFFSET($A$1,0,0, COUNTA($A:$A),COUNTA($1:$1))
which expands across Columns in Row 1.
What if we don’t know range to be named in which row or column starts?
What will be a formula (assume range starts on cell named “BegRng”)?
View 3 Replies
View Related
Nov 10, 2009
I have a macro that is copying information from one spreadsheet into columns "A through E" on the next available row in a seperate spreadsheet. Beginning with column "G through L" I need to copy the formulas from the row above in the same spreadsheet. Is there a way to do that since the row being copied from will change each time?
View 4 Replies
View Related
Sep 11, 2013
I want to select a range of rows 11, 14 and 23 to 24 in column j, plus the 2 rows to the right of column J and run a sum formula on the range. My procedure is selecting rows 11/14/23/24 and doing the sum for only column J. How do I make it so it runs the sum formula on all 3 columns. My code is copied below. I am fairly new to VBA.
Code:
With ActiveSheet.Range(Cells(27, j), Cells(27, j)).Select
Set sumRng = Intersect(Range("15:21, 25:25"), Columns(j)).Offset(0, 2)
ActiveCell.Value = WorksheetFunction.Sum(sumRng)
End With
View 4 Replies
View Related
Mar 5, 2007
I need to change multiple conditional formats which apply to cell ranges 1 row x 17 columns wide. The specific change I am making is able to be acrried out with the code
With Selection.FormatConditions(1).Font
.ColorIndex = xlAutomatic
End With
However, I dont want the user to have to manually select each 17 cell area. I WANT THE USER TO JUST MANUALLY SELECT THE FIRST OF THE 17 CELL AREA. I want to write a macro that will THEN select a row of cells, 17 cells long, from the MANUALLY SELECTED position as at the moment of running the macro. Unfortunately the cells are not always on the same row in each sheet. On one sheet they may be on row 5, on another row 8 and on another, row 15 etc. I was wanting to be able to select a 17 cell range 'relative' to where the cursor is. How do I write the code to select the relative cell range? Is there an answer in an R[1]C[1]:R[1]C[17] sort of code?
View 7 Replies
View Related
Feb 11, 2014
I would like to loop through cells row wise.
Columns which have data are A:E
modify below code to select the range from columns A to E?
[Code] ........
View 3 Replies
View Related
Jan 28, 2014
I am trying to select rows in excel using a macro and then hide the rows, but i want to be able to add rows within this selection and still be able to hide the complete selection of rows.
The macro i am currently using is shown below: This hides rows 131 - 205, but if i was to add in another row in between so the range i now want to hide is 131-206 can i get the macro to update to this new range?
[Code] ......
View 10 Replies
View Related
Mar 13, 2014
I'm using the VBA code below for a piece of code.
[Code] .....
However, I want to use this same function in another place, without the limit set on the cells that will be cleared.
What I would like to do is send the formula the cell to start at (E14), offset that by one column, and then send a number of rows. With that, create the range to be cleared.
Something like:
[Code] .....
View 3 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
Mar 10, 2014
Using VBA, I need to Select A1:C14.
The problem is that A1:C14 contains blank cells, and there is also an adjacent column D that I do not want to copy.
So, UsedRegion and CurrentRegion aren't doing it for me. (It selects Column D too.)
Obviously, this is an example...the real data set is an export and varies in size.
View 1 Replies
View Related
Apr 24, 2014
I'm attempting to match a name with the row and column numbers of data that is laid out in a grid format. It looks something like this:
Denson
Matthews
Smith
[Code]....
This works just fine, except for the fact that once in awhile the same name will appear in the grid twice, and the row and column returned will be off (it will return the row for one of the Smiths, for example, and the column for the other).
I know why this is occurring so I'm looking for a better way to do this. The good part is that I don't necessarily need both locations returned for each "Smith" ; I just need the correct row and column for at least one of the instances. I'm looking for a better way to do this.
View 1 Replies
View Related
Mar 22, 2009
In 1 cell i need a forumla to give me a starting number and take one away each time a code or codes are dislayed in a cell range. Something like this
A1 = 23 days or any number days i needed
Cell range B1:C52
every time a selected 1 or 2 letter code appears in the cell range i want A1 to subtract 1 day from the starting number, i would need it to subtract half a day if one code appears ie HD, the codes may be P, OT, HD
View 4 Replies
View Related
Dec 16, 2006
how to delete complete rows that in column a end in the letter A
View 6 Replies
View Related
Mar 19, 2005
I'm sure there is simple code for this but I have excel spreadsheets like the sample attached that are consistant in the types of fields but the only data I want to strip out are the rows where column A has a "G" in the cell, I tried using this
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
but this doesn't work when there is only one row of data. The number of rows with valid data will vary each day. I then tried an if, then statement and a loop but I could never get the loop to stop. I basically want a macro which parses through the worksheet and selects the rows that have that "G" in column A so I can copy them and paste them in another worksheet.
View 8 Replies
View Related
Aug 20, 2014
I need to unhide 2 rows at a time starting with rows 28 and 29 IF cell N28:O28 > 0. I need this to be for rows 30 and 31 IF cell N30:O30 > 0, rows 32 and 33 IF cell N32:O32 > 0, rows 34 and 35 IF cell N34:O34 > 0, rows 36 and 37 IF cell N36:O36 > 0, rows 38 and 39 IF cell N38:O38 > 0, rows 40 and 41 IF cell N40:O40 > 0.
There is currently a formula in each of the selected cells that is why I was going for greater than zero.
View 1 Replies
View Related
Jul 15, 2013
I have a large set of data regarding the activities going on in particular rooms. The data contains activity name, start time, day, duration, room and size.
I would like to select all rows that contain a cell in the activity name column which contain the words 'VideoConference'.
I have tried to Search, Select All then index the remaining data using =iferror(index(etc. However some activities occur in more than one room and all variables apart from 'Room' are the same. Thus when I have tried to index the room column I get the same room for both rows.
ps the raw data set consists of +28000 rows so I can not simply look through and copy.
View 4 Replies
View Related
Aug 15, 2008
Question 1) Is there a way that whenever I select Cell B39 that it will copy cells B39:V39 ? From there I can manually paste that selection to where I need to.
If this is possible, it would save the effort of having to select B39:V39 manually and clicking CTRL-C. I am gathering data and the copying and pasting is killing me.
Question 2) Is it possible that when I click on Cell A9 that it can paste any data that I just copied from another worksheet to cells A9:D29? The size of the selection that I would copy is the same size as A9:D29 (4 columns & 29 rows).
I have searched for a solution, but I am not having much luck since I am anaware of the proper terminology for these types of actions.
View 10 Replies
View Related
Oct 24, 2008
how (in VBA) to select a range within a column where all values are the same?
For example, given the following:
A B
1 ID Value
2 1 A
3 2 A
4 3 A
5 4 B
6 5 B
7 6 C
How would I select range(B2:B4) where all values = A?
View 14 Replies
View Related
Oct 14, 2008
I need a cell to display the (text) content of 1 of 25 cells. example: I have text content in all cells ranging A1:A25. I want cell B1 to display the content of 1 of these at random. is there a function for this or do I need to use a macro?
View 4 Replies
View Related
Feb 27, 2009
I have rows of data, and the first number corresponds to the number of subsequent numbers that are relevant.
I want to paste that number of values into a second spreadsheet. How do I do this?
e.g.
A1 B1....
6 21 15 14 32 85 14 16 21 25 26 24
In this case I want to copy the 2nd-7th number, as the 6 tels me I want the next 6.
View 9 Replies
View Related
Oct 21, 2009
Is it possible to select only cells of a certain colour, then change these cells to a different colour? example
I want to make the dark grey columns a light green and the red columns a lets say yellow and the text black. Is this possible??
View 9 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
Jul 29, 2013
If Cell "B55" Cell is selected and I want to Select all the above rows to select till Row 1. Selected Row mught change Say B66 or B82 (Dynamic)
Whatever may be the Cell Selected, The result should be The above rows should get seleted. So that I want to delete the rows easily
HTML Code:
ws.Range("B55").Select
Range(ActiveCell, Activecell.Offset(-55,15)).Select
'This cannot work if the selected Cell is 65, So this should be Dynamic till above Range 1)
View 2 Replies
View Related