Pass Row Number From Range Whos Address Is In Cell
Aug 18, 2007I am setting a variable to the value of an absolute cell reference. I want to set the value of another variable to just the row value of that absolute cell reference.
View 4 RepliesI am setting a variable to the value of an absolute cell reference. I want to set the value of another variable to just the row value of that absolute cell reference.
View 4 RepliesFollowing statement works for me:
bdcTerm1 = ThisWorkbook. Sheets("ws2"). Range("A1").Value
But instead I want to parse through 50 rows and dynamically get the value instead of using a static Range("A1"). So I am trying to do the following:
For Row = 1 To bdc_rows
bdcTerm1 = ThisWorkbook.Sheets("ws2").Cell(Row, 1).Value
bdcTerm2 = ThisWorkbook.Sheets("ws2").Cell(Row, 2).Value
Next Row
But I get errror.
I am trying to create a macro (please look the attached excel what I have done), I have already crwated a macro that after 5 seconds is gonna change the background color of the of the cell en function of another cell.
That means if F3:F4 change the background color F8:is going to change the backgorung color also, every 5 seconds. The macro I wrote is also include in the excel attached file.
Now this is my problem... I have a variable cell that is give for D6 which could be A,B,C,D,E,F (Range F2:K2).
If the variable cell D6 is A the background color of F8:F9 should be the background color F3:F4 .
If the variable cell D6 is B the background color of F8:F9 should be the background color G3:G4 .
If the variable cell D6 is C the background color of F8:F9 should be the background color H3:H4 ......and etcetera.
I have uploaded a copy of the spreadsheet I am working on and have completed the user forms and coding for march the 1st only, so if you test, please use the options march and then the 1st!
The problems i have is, when I enter a number into a text box and press next page, the numbers fill where i want them to but the cells do not recognise them as numbers, therefore conditional formatting doesnt work! Even if I change the cell properties to numbers, this does not remove the error!
Second problem!! If a user forgetts to enter a value in a box, or they wish to edit just one value, and go back into the user form to change a figure, when they press next page, all the values in the column seem to disappear!
I use the code below to enter a value from a list box in a cell on a workssheet. Is it possible to code VBA to enter a number for the position of the selection in the listbox to a cell in a worksheet rather that the actual value from the list box. For example if my list is:
Option1
Option2
Option3
And I click on Option2 in the list, I can sennd the value 2 to a cell on the worksheet rather that the value "Option2' from the list.
Private Sub ListBox1_Click()
Sheets("SA").Range("SA_Poistion_To_Archive_A_New").Value = ListBox1
End Sub
I am building a Workbook which takes data from SheetA and inserts it into SheetB.
Part of the data is only entered when a positive value exists.
I then do an export from SheetB.
The problem is that I need to get the column number and pass it to the cell reference based on the field name in row 1.
Dim sFindstring As String
Dim rFindcell As range
Dim iR As Integer
Dim iC As Integer
sFindString = " Find this string in the cell"
'Using cells find the findstring
Set rFindCell = Cells.Find(What:=sFindString, After:=[A1], LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
'OK so look here
iR = 3
'I am trying to pick up the column number
iC = rFindCell.Column
rFindCell throws an object or with block variable not set error. Is there some property that I need to set.
I need to pass range information (eg. WorkSheets("abc").Range("A1") as text or ??) from a cell (ie the above text is in a cell on some worksheet, say "XYZ") to a VBA procedure or could directly use it in the procedure, similar to...
Sub MyProc(RngInfo as string [or?])
dim RRng as range
Set RRng= RngInfo ??? it is this part I'm really not sure how to do
where RngInfo is a worksheet that has a "named" cell that contains the above cell with the indicated range in it.
eg. RngInfo is worksheets("XYZ").Range("D1") where D1 contains the text (or ?)WorkSheets("abc").Range("A1")
I've only indicated these as text items because I'm not sure what/how you would do this. The end purpose of this is to pass variable Range information from a cell on a WS either into (or use within directly) a VBA Sub. I guess I could pass the WS and Range Address as a single string separated by a "Char" and use Split to separate them and then recombine using Worksheets(Parm(0)).Range(Parm(1)) but it seems like it should be easier than that.
I have the following formula which works fine in this form:
View 4 Replies View RelatedI have workbook template that I use to generate reports from a list of depts. This list is contained in a drop down cell that is a named range in a different worksheet. My current process is as follows:
-Select Dept Name from the list
-Click a command button which is assigned to code that calculates and saves to a file
-Repeat for next report until all reports are generated
I would like to automate this process by producing all reports with a single command with the following functionality:
-The Dept Name needs to be populated in the specified cell containing the current drop down because it drive various vlookups and other formulas
-If possible, I would like to retain the drop down functionality as I would like to have the option of running an individual report or running the “batch”.
What formula can i use to obtain the address of the cell which contains the highest number? My range is A:A
View 2 Replies View RelatedI have a Choose function that is used to determine which range I need. e.g. =Choose(Choice,Cell,Cell,...).
In each corresponding "Choice" cell is a typed range. e.g. $B$33:$L$70
I'm looking for a way to be able to use this typed range as the range for some chart data.
I know that I can return the value of a defined name range, the address, and even the value of the define name, but if you are given a range address, how do you find its corresponding defined name in code?
View 4 Replies View Relatedi'm looking to return the cell address of the max number in a given range?
View 3 Replies View RelatedI have something like the following:
If Worksheets("RawData"). Cells(1, nColumn).Value = Worksheets("RawData").Cells(12, 16).Value Then
..do code (I know the cell location of interest at this point)
End If
Then I End up needing To Do something Like the following
ActiveChart.SeriesCollection(1).XValues = _
Worksheets("RawData").Range("L1:N1")
“L1:N1” above is a sample. Given the code above it I have the cell location in question but it is in the format such as .Cells(12,16). That doesn’t do me much good when range wants something like “L1”. I don’t know how to convert that (12,16) to a L16 for example.
I have to macros I'm working with the first take a user set range and prints the . Address to a cell.
The second Macro I'm trying to get to look at that cell and pull out the range. So is there an opposite fuction to .
Address that will convert excel format to a VBA Range format. Ex A cell with $A$1:$A$2 to Range("A1",A2")
Macro 1
Code:
For j = 1 To x
c = 1
For i = 1 To ws.Range("AD" & rc).Value
ws.Range("AE" & rc).Value = Application.InputBox
(Prompt:="What is the Heading of Data set #" & c & " Table " & tc & " This entry may repeat", Type:=8)
[Code] .........
Macro 2
Code:
'A lot of code here but I want to be able to set multiple ranges to the ranges list in the cell values.
rng(2) = sh(0).Range("AG2").Value
I have a variable which contains the column number. How do I then reference a range in VBA using that column number, as opposed to the letter? I know how to convert the number into the letter, but I also know there has to be something more simpler. For instance, a form of the ADDRESS function, but in VBA?
View 9 Replies View RelatedI 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
I've set up a macro to create around 50 http links (sites which i need to monitor every week but whose addresses change slightly every month)
I've also got a macro to open up all these web pages at once so I can look at them in internet explorer.
When these links are nicely created into cells the http link isn't recognised straight away by excel (e.g. doesn't go blue & underlined) until i click in the cell & change or return the cell value - as part of the autocorrect function i think.
Is there a way of getting excel to automatically recognise the http links without having to go individually into every cell.
If I added two numbers together in one cell - how can I use the result as a cell address? example. A3=23+5 now I want to use A3 (or 28) as a cell address resulting in D28
View 4 Replies View Relatedconstruct a formula that finds a value in a range , then returns the cell address of that value.
Say, i wanted to find the amount 12385 from another sheet , range C2:AA12 (contains only numbers , no duplicates). result should give me the address of that value.
I have tried the address & match function but gives me an N/A error.
Retrieving the address of the last cell before the FIRST blank in a range.
OK, I have searched the web through six different search engines and explored too many dead end solutions to this problem that I am nearly ready to just scrap the whole sheet.
The problem is very simple.
I need to return the address of the last cell that contains data before the FIRST blank cell.
Heck, I don’t even need to have the address, I can just index the position.
Problem is this question has been posted on nearly every excel help forum from here to pokipsy.
Unfortunately EVERY solution I have seen fails the “FIRST blank” requirement.
I have a column of data that never has blanks until the end of the data. I need to know what that cell address is in order to identify a range.
This data has a table above it and below it so none of the “dynamic range” or “Dynamic range name” solutions will work.
How do you get that address without the function continuing to the last blank cell?
I have a named range BGl (G1:R1). I would like to see if a cell address ($U$6) is within the columns of that range. I need a function to give me a true or false based on changing cell addresses.
View 5 Replies View Relatedwhen I use the range.find function to find a certain value in a column.. i want to return the address of the cell.. and save it in a range variable. how would I do that?
so this is what i have now.. but Rng does not return as a range.. it returns 69... when i use ctrl + G and type ?rng
set rng = .range(A:A).find(what:=69, After:=.Cells(1, 1), Searchorder:=xlByRows, searchdirection:=xlPrevious)
ok so say it picks up..... cell A69... how do i get it to save range A69
Let's say Cell is a cell.
How do we select this cell's column? I tried :
Cell.Column
but it doesn't work. I have an error message.
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
I am trying to create an XY scatter plot with multiple series. Normally, one has to manually type in or mouse-drag a range for each x series and y series. Instead I would like to build these two ranges (x and y) with text functions and place them in a cell.
For example:
A1: 'data'!$C$3:$C$10
B1: 'data'!$D$3:$D$10
Then, when I create a chart, instead of mouse-dragging, for the x-series, I'll indicate the range that's specified within Cell A1, and for the y series, that which is in B1. I would then repeat this for each series. The reason I want to do this is because I have dozens of series and dozens of graphs and it is relatively easy to programatically identify the range boundaries, but long and tedious to mouse drag them.
I have a sheet with multiple tabs - 1 per employee. I'm trying to run an index on a select tab based on the contents of a cell in order to do a summary across all employees/tabs.
The person's name is Tulley and is listed on the summary page in cell A11. =INDEX(TULLEY!$B$4:$M$5,1,$B11) returns the correct value. I would like to replace the tab reference with the name of the person concatenated with an exclamation point. This yields TULLEY! -
INDIRECT("A11")&"!". I thought that I would be able to replace the TULLEY! in the index formula with the indirect formula. This formula returns TULLEY!, but the index function doesn't work: =INDEX(INDIRECT("A11")&"!"&$B$4:$M$5,1,$B11).
I am looking for a formula that returns the cell address of the last cell > 0 in a range.
in the example: A1CLA23 8
4546557528
the result should be A7.
Here is a sample of database,
A
1
Jan-12
2
Feb-12
3
Mar-12
4
Apr-12
5
May-12
6
Jun-12
7
Jul-12
8
Aug-12
9
Sep-12
10
Oct-12
11
Nov-12
12
Dec-12
If i lookup a value in the range A1:A12, say Sep-12, i need to get the cell address instead of the value of the row. but i know how to get cell address using CELL function. but i need to get cell address when i lookup the value.because lookup value will be dynamic.
I am performing a lookup using the populare user defined function nlookup, which does not take a lookuparray argument to find lookup values. But I only want to return lookup values that fall into a certain array. To accomplish this, I figured out that I need a way to specify a condition of the type "if cell address of lookup value falls within range"
It should be possible if I find a way to return the cell address of the nlookup value, but as nlookup is not limited by a lookuparray argument, so I was not able to use the address/index/match that come up in similar questions.