Define Single Cell Range
Apr 4, 2007
I'm having trouble assigning a range of a single cell using vba. I'm doing this to create charts. Here's the sub containing the problem
Private Sub AddNewSeries(Target As CTarget)
Dim i As Integer
Dim Match As Boolean
Dim rValid, rInvalid As Range
i = 2
Match = False
Do While Match = False
If Sheets("Graph Data").Cells(1, i) = ReportTargetBox.value Then
Match = True
MsgBox ("report name match")
Exit Do
Else: i = i + 1
End If
Loop.....................
This msg box :MsgBox ("Cell Value = " & Sheets("Graph Data").Cells(2, i).value) is working and returning the correct value.
View 2 Replies
ADVERTISEMENT
Feb 26, 2014
is there a simple way to do a vlookup (or any other more appropriate formula) using the value of another cell to define the named range relevant to that lookup.
eg I will have two different ranges for fitness performance levels, each of these will be named "Male" and "Female".
I would like to do a lookup based on a formula as follows: Try this formula. Column letter & Row number are for example only. Array formulas will have curly brackets {} emcompassing the ENTIRE formula. You do not add these, you Enter the formula with Ctrl+Shift+Enter and Excel will add them (details: Array formulas). Many more Excel Formulas Z100 =vlookup(D4,NAMED RANGE,2,false)
the Named range would be a value in the same row ie B4 - being Male or Female
so I am hoping for something like Try this formula. Column letter & Row number are for example only. Array formulas will have curly brackets {} emcompassing the ENTIRE formula. You do not add these, you Enter the formula with Ctrl+Shift+Enter and Excel will add them (details: Array formulas). Many more Excel Formulas Z100 =vlookup(D4,B4.Value,2,false)
otherwise I could just use an If and do something like: Try this formula. Column letter & Row number are for example only. Array formulas will have curly brackets {} emcompassing the ENTIRE formula. You do not add these, you Enter the formula with Ctrl+Shift+Enter and Excel will add them (details: Array formulas).
Many more Excel Formulas Z100 =if(B4="Male",vlookup(D4,Male,2,false),vlookup(D4,Female,2,false) )
View 2 Replies
View Related
Jan 27, 2009
How can I define a range, only for the active cell?
View 6 Replies
View Related
Feb 14, 2013
The way I have try to define lastcell is wrong. But I don't know how to do it.
Code:
Sub createUniqueRecordID_2()
'
' fill using CTRL + ENTER
'
Dim lastcell
Sheets("projects list").Select
[a1].Select
[Code]...
View 1 Replies
View Related
Nov 22, 2006
I want to define the range from a given cell and all data below within the same column strDataStart is the named cell in the worksheet that want to start from. Below is what I tried and failed.
Function rngDataCol(strDataStart As String) As Range
Dim rngDataEnd As Range
rngDataEnd = Range("strDataStart").End(xlDown)
rngDataCol = Range(Range("strDataStart").Address, rngDataEnd.Address)
End Function
View 5 Replies
View Related
Jul 21, 2009
I have a range staring with cell "A5" and going to Column "K8+" that I need to copy. My issue is that the number of rows to copy will change. I have the number stored a variable "a" in my coding. how do I code this to work?
View 5 Replies
View Related
Jan 23, 2007
I want to define a Range() in VBA. have cell1 and Cell2 in the format of rows and cols. ie. Cell1 = Row 1, Col 2. Cell2 is dynamic, can be sometimes row100, Col200, or Row23, Col 1000. May i know how to define it in VBA?
View 2 Replies
View Related
Jul 2, 2012
I have a range of cells each containing a name. Based on a number that has to be entered manually I want excel to return the names concatenated in one cell. So for example:
Number of variable entered: 5
q9001
q9002
q9003
q9004
q9005
q9006
etc.
Should give me: "q9001 q9002 q9003 q9004 q9005"
I have been trying to work with formulas using IF and CONCAT functions. But so far I haven't figured out how to have excel return me the correct amount of variables for each separate number that can be entered seeing the number of variables entered can vary from 1 up to 50.
(Using Excel 2010)
View 7 Replies
View Related
Aug 1, 2014
I am in need of a way to pull keywords listed in B2:B10 from text in A2:A10 and then those pulled keywords combined in cell C11.See attached document. So I have colors for keywords in column B and some random text in the column A including the keywords in parenthesis. Is there a way for a formula to find all keywords in A2:A10 and then list them in cell C11 with commas in between.So the result would be one cell C11 showing BLUE,GREEN,BLACK,ORANGE, etc.I have been trying to mess around with index and match and while I could get one to pull up I don't know how to combine it.
Keyword Range.xlsx
View 5 Replies
View Related
Jun 24, 2014
I am reading this fomular and cannot understand it.
=SUMPRODUCT($Q$13:$Q$309,($P$13:$P$309=$D20)*1,($O$13:$O$309=H$8)*1)
Basically each input should be a matrix and the first one really is. However the other two are not and look unfamiliar to me.
View 1 Replies
View Related
Nov 25, 2009
I want the numbers to give me a sum total if a cell that is not in the row contains an "x". Row of number from A1:A5 each cell has the number 1 in the cell. if there is a x in cell A2 i would like to get the sum of the numbers in A1:A5 in cell A3.
was trying =SUMIF(A2,"x",A1:E1) this is the formula in cell A3
I am expecting the result of 5, this formula returns the value of 1 since there is only 1 x in cell A2.
View 2 Replies
View Related
Mar 20, 2009
I have a workbook with a named range myrange, cells a2:a1001. I have counter as a named range, mycount cell z2. I want to get the value of myrange at cell address mycount and put that value elsewhere using vba.
View 2 Replies
View Related
Jan 18, 2011
Here is the set up:
I have a calendar sheet where the dates go down the rows, and there is one column per member of staff. The staff is split in to three streams (different apps to cover, etc).
In the calendar, we mark a "C" for when someone will be on-call, R for when they will be doing a release, and so on.
In a separate sheet in the workbook, rather than having people look at the whole calendar of 30+ people to see who is on what shift for a given stream, I have an On-Call Rota where the rows are again the dates, and the columns are the streams. In each cell of this sheet, there should be the names of all the people of that stream who will be on-call for that date, so a concatenation of the actual staff members from the calendar, separated by CHAR(10).
I have been unable to find a combination of INDEX, MATCH, LOOKUP, VLOOKUP, etc, etc that gets me past the main problem: they only ever match the first C (or the first R for the On-Release Rota). I can't get a formula for a single cell in the rota that will return all the names where there is a C in the calendar in such a way that I can concatenate them.
Here is the kind of thing I have had to do .....
View 7 Replies
View Related
Nov 6, 2008
I have a large amounts of named ranges each of about 100 rows 20 column's each in its own sheet and I need to be able to refer to a singe cell in that range.
I want to do this so that I can use an offset to get another cell value relative to the cell in the named range.
F9 contains a hyperlink to the named range and is the same as the named range but with spaces.
A couple of things that I have tried are below:
=OFFSET(INDIRECT(SUBSTITUTE($F9," ","_")),1,0)
=OFFSET(VLOOKUP("bob",INDIRECT(SUBSTITUTE($F9," ","_")),14,FALSE),1,0)
Neither of these work, I am asuming it is because I dont have a specific cell reference named for the offset?
View 9 Replies
View Related
Aug 5, 2006
I am trying to make this macro look at multiple cells in column X and perform the given operation based on what is found. I currently have it set to look at one cell, I am not sure how to make it look at a range of cells and change its cell refrences for the copy function.
Dim vS As Variant
vS = Sheets(3).Range("X5")
If Not IsNumeric(vS) Then
Exit Sub
Else
Select Case vS
Case 1
If MsgBox("Are you sure you want to delete?", _
vbYesNo, "ExcelTips") = vbYes Then
Application.DisplayAlerts = False
Sheets("Approved").Select
Range("B5:F5").Select
Selection.Copy
View 9 Replies
View Related
Jan 21, 2010
I have two columns containg the arrival and departure hours of workers. From these columns I must define the workshift by specifiyng the time range for each shift. AZ contain the arrival hours while BA the departure.
The formula I use doesn't return the results correctly because some shifts are almost the same. i.e: if shift one starts (arrival hours) between 05:00 and ends at 12:59 and shift 1-2 starts at 08:00 and ends at 23:59 then it will go with the first shift even though the times in range belong second shift.
View 8 Replies
View Related
Feb 23, 2013
why this won't work.
Code:
Dim DRange As String
Dim ERange As String
Dim SRange As String
EndRow = Range("A65536").End(xlUp).Row
DRange = Range("D1", "Z" & EndRow)
ERange = Range("E1", "Z" & EndRow)
SRange = DRange
View 6 Replies
View Related
May 19, 2008
how to define the end of a range using a variable determined by a rng.Rows.Count command (or anything else)? Is this even possible? Here is what I currently have:
Set rng = Range("A1:A10000")
For i = rng.Rows.Count To 1 Step -1
If rng.Cells(i).Value = "0" Then rng.Cells(i).EntireRow.Delete
Next
I'd like to define the end of the range with more accuracy than I'm currently doing.
View 9 Replies
View Related
Apr 25, 2006
I'm trying to define a range to be copied during execution of a macro. The range to be copied must include all contiguous data from a defined starting range to the rightmost column and the bottommost row containing data (boht of which can change depending on input data). I use <End>+<RightArrow> and <End>+DownArrow> to define the range when working in Excel (not under macro control).
I used the macro recorder to define the code for the process described above, with results shown below:
Sub Macro2()
Sheets("Source_Info").Select
Range("A2:D6").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Working_Data").Select
Range("A2").Select
ActiveSheet.Paste
End Sub
When I run the macro, however, the End(xlToRight) and End(xlDown) commands do not have any effect (i.e., the rang is not made any bigger when these statements are executed).
I've used the same code in previous macros (with previous versions of Excel and Windows), and it worked fine. I'm running Excel 2003 under Windows XP Professional now.
View 5 Replies
View Related
Aug 13, 2006
is it possible to creaate a macro to highlight a range that starts at a1 to a? and there could be blanks amongst that range. the range will be unknown
View 9 Replies
View Related
Dec 22, 2006
I am searching for data, upwards from cell A1400. Once I find data (cell > 0), I need to count up 27 rows and then select these rows for columns A to E. Then I want to copy this block of data and paste it. I have been having difficulty with the selection of a block of data which will be in a different position depending upon the data used. The code I am using is below. The two lines that I need to replace with a Variables cell range reference are:
Range("A1268:E1242").Select
Range("A1268:E1242").Activate
Sub CalculateATR()
Sheets("Data").Range("a1400").Select
Do
If ActiveCell.Value > 0 Then
ActiveCell.Select
Exit Do
Else
ActiveCell.Offset(-1, 0).Select
End If
Loop Until ActiveCell.Value > 0
Range("A1268:E1242").Select
Range("A1268:E1242").Activate
Selection.Copy
Range("G5:K31").Select
ActiveSheet.Paste
Else
End If
End Sub
View 8 Replies
View Related
Feb 7, 2007
how to set up an array within a worksheet
View 3 Replies
View Related
Mar 26, 2008
how do you go about referencing a cell by using a value of an integer? For example, I want to select cell A5. I have the number i= 5 (in my vba code) and I want to use that together with the row letter A.
View 4 Replies
View Related
Jun 2, 2014
I've managed to write a macro to take data input into a column-oriented form and transpose it into the next available rows in 3 data sheets. In the blank workbook, you will find a functional data entry form with a "submit" button that transposes data from the first column of the form to the next available row in sheet "Data_R", data from the second column of the of the form to the next available row in sheet "Data_I", and the sum of both columns to the next available row in sheet "Data_C", clearing the form for further use.
Now, I need adding to the macro code that will sum data from the constituent columns of each multi-column category header (Marketing, Intake, etc.) in sheet "Data C", entering the sums under their respective single column headings in the next available row of sheet "Data_S".
I need to do this in order to use Defined Names (utilizing the OFFSET function) to create charts comparing the different categories that automatically update as new data is input via the form. I know how to do this, I just need the multi-column categories summed into single columns to make it work.
View 9 Replies
View Related
Nov 30, 2008
The problem exists with the lists I use. I have a "settings" sheet, where users can choose from preset values to run in the program. E.g. "Urgent", "Semi Urgent" and "Non Urgent" (there are a lot more values, but those will do for now." and the idea is to run them 1 at a time.
However, I've now determined that 99% of the time, they're going to be run 1 after another, that is to say run the program once for "Urgent", then again for "Semi Urgent" and then again for "Non Urgent". So I'd like to loop through these. Again, not a problem, you'd think.
So I added a new value to the list; "All" which users can select to invoke a list. Again, not a problem, I already have the list as a named range, "DmgList" and I can cycle through it. I ran the following test code to see if it would work in theory...
View 4 Replies
View Related
Mar 30, 2013
How can I identify the last cell of a single column range . . . i.e. the last cell address of range C1..C15 is C15. The range will have a name of "reg".
View 9 Replies
View Related
Mar 10, 2008
i have my data in coloumn G. and i am trying to create a macro to copy all the data in coloumn G:G to cell K1. i am doing this so i cand simply extract some data to other cells useing the search formula.
View 9 Replies
View Related
Jan 12, 2009
The following does paste the formula into the dynamic range, however, it doesn't move on to the next step in the code. It seems to get stuck on the last line. I let it run for 5 minutes and it still did not move to the next set of commands ...
View 9 Replies
View Related
Mar 4, 2009
How can I merge into a single cell from a range of selected cells that contain text. If the range of cells do have empty cells it should be smart enough to skip over or not to create an additional space. Any idea how can this be done? Macro or formula?
View 9 Replies
View Related
May 18, 2007
I have a list of ID's on one sheet that are also located in a large matrix on another sheet.
This macro uses the Find_Range function to find each ID within the matrix and return the column header where the ID was first located.
There is also a line which return a list of ranges, indicating all the places where the ID was found.
What I want is to convert the list of ranges into a list of corresponding column headers (ie row 1 of all columns in the range)
' Number of id's in list
RowCnt = Application.WorksheetFunction. CountA(Columns("A"))
For I = 2 To RowCnt
LookFor = Sheets("ID List").Range("A" & I)
Set InRng = Sheets("Matrix").Cells
Set Found = Find_Range(LookFor, InRng, xlValues, xlWhole)
On Error Resume Next ' If value is not found
Sheets("RateID Count").Range("C" & I) = Sheets("Matrix") _
.Cells(1, Range(Found.Address).Column) ' Return column header
Sheets("ID List").Range("D" & I) = Found.Address(False, False) ' Return cell address or range of addresses
On Error Goto 0
Next I
View 9 Replies
View Related