Refer To Variable Cell Row Number

Jun 28, 2007

is it possible to refer to a cell by a variable cell number? For example suppose i want to refer to a cell on column B, by a value which is in cell C1, so the if C1 has the value 7, i would refer to cell B7, abd if it has the value 87 i would refer to cell B87.


Refer To Cell To Update Row Number In Index Formula?

Dec 8, 2012

I have 2 excel files A & B. In cell A1 of file B, I use an index formula to refer to a row in file A. "INDEX('[A.xlsb]A'!$10:$10,1,2)" is the formula used (referring row 10 in file A).

If I update the row number in another cell of file B, is it possible for this formula to refer to that cell to get the row number from file A?

View 1 Replies View Related

Refer To An Array Variable In A Formula

Nov 30, 2008

I'm trying to use arrays in a macro!

Here's my
Sub ArrayTest()
' ArrayTest Macro
Dim Array1() As Variant, Array2() As Variant
Dim R As Integer, ilR1 As Integer, iLR2 As Integer
ilR1 = Cells(Rows.Count, 1).End(xlUp).Row
iLR2 = Cells(Rows.Count, 7).End(xlUp).Row
ReDim Array1(1 To ilR1)
ReDim Array2(1 To iLR2)
For R = 1 To ilR1
Array1(R) = Cells(R, 1) & Cells(R, 2) & Cells(R, 3)
Next R
For R = 1 To iLR2
Array2(R) = Cells(R, 7) & Cells(R, 8) & Cells(R, 9)
Next R
For R = 2 To UBound(Array1)
If WorksheetFunction.CountIf(?????, Array1(R)) > 0 Then Cells(R, 4) = "old" Else Cells(R, 4) = "new"
Next R
End Sub

Basically, the macro concatenates the content of three columns from two different tables into two arrays. Array1 contains the current stuff and Array2, the old one. If I CountIf items from Array1 into the content of Array2, I should get what's new (count 0).

Now, ? in the code should refer to the content of Array2. How do I do that?

The errors I get are 424 object required [Array(iLR2)], 1004 method 'Range' of object '_Global' failed [Range(Array2) or Range(Array2(2), Array2(iLR2))], or type mismatched [Array2].

View 9 Replies View Related

Variable To Refer To A Worksheet.CodeName

Jan 22, 2009

This is a simplified version of an earlier, long winded post that clouded my actual question.
Can I use a variable to refer to a worksheet by its CodeName? For example, let's assume I have several worksheets, with CodeNames of mySheet1, mySheet2, mySheet3, and so on. I understand that I can refer to them directly,

mySheet1.Range(myRangeName).value = someValue
mySheet2.Range(myRangeName).value = someValue
mySheet3.Range(myRangeName).value = someValue
but what if I want to do this using a loop? Is it possible to preload an array of CodeNames and do it that way? I'm thinking along the lines of something like...

Dim CodeNames
CodeNames = Array( mySheet1, mySheet2, mySheet3 ...)

For x = 1 to HoweverMany
CodeNames(x).Range(myRangeName).value = someValue
Next x

View 9 Replies View Related

Pass Cell Value Using Variable Row Number

Aug 15, 2008

Following 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.

View 5 Replies View Related

Remove A Variable Number Of Characters In A Cell

Jul 7, 2008

way to remove a varible number of characters in a cell? My example is in cell range A1:Z1 and each cell could have a different number of characters.

Smith, Sally 5348
Jones, Johnathan 7893
Doe, Mike 2223

What I would like to do is remove the second space and the numbers that follow to get a result of

Smith, Sally
Jones, Johnathan
Doe, Mike

View 9 Replies View Related

Find Row Number Of Cell & Pass To Variable

Aug 4, 2007

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.

View 5 Replies View Related

Insert A Variable Number Of Rows And Copy And Paste From And To Variable Positions

Aug 8, 2009

On the attached Excel file, I have code that will insert a variable number of rows and copy and paste from and to variable positions. That all works fine when run from a command button, but when I try to run it from the Worksheet_Calculate by entering 1 in J1 or K1 (inrange cell is J1+K1 for testing purposes) the CommandButton1_Click sub runs continously until an error occurs.

View 4 Replies View Related

Excel 2007 :: Get Cell To Refer To Date That It Contains And Change Cell Colour Based On That?

Dec 19, 2012

I work for a UK charity and have a list of funders in an Excel 2007 spreadsheet.

One of the columns refers to the date on which a new application for funding can be made to that particular funder.

In many cases new applications for funding can't be made for 1 or more years since the last application - sometimes as many as 5 years later. How to get a cell to refer to the date that it contains.

For example, say I have in cell A1 "The Acme Funding Organisation" and in cell B1 (i.e. the "Reapply when?" column) a date of 01/04/2013 (British date format, i.e. 1 April 2013) then what I want Excel to do is to look at the date in cell B1 and if that date has been reached to highlight the cell red. That way I'll know that the reapply date has been reached & that a new application can be made.

View 2 Replies View Related

Refer To Cell Without Offset

Aug 31, 2012

I have a selection that I am going through with a 'for each' and then performing actions if the cells meet a certain criteria. I have been referencing nearby cells with the offset function, but now my sheet is too big and I need to change the code often and the offset function is difficult, is there anyway to refer to cells without the offset function, preferably by column letter

PHP Code:

For Each Cel in SelectionIf Cel = x Thenvalue1 = Cel.Offset(0,39).Valuevalue2 = Cel.Offset(0,5).ValueEnd IfNext Cel 

View 9 Replies View Related

To Merge Variable Number Of Cells Into One Single Cell Based On Criteria

Sep 19, 2009

Heres an example of my data:


I need your help to figure out how to merge the above data to look like this in new blank worksheet using a VBA macro:


View 10 Replies View Related

Conditional Formatting - Refer To Another Cell

Dec 31, 2013

In conditional formatting, which formula do I use to refer to another cell? Trying


without luck.

View 9 Replies View Related

Using Text In A Cell To Refer To Worksheet Name

Jun 6, 2003

How can I use (with or without macro) cell text to refer to different worksheets inside a formula. For example I've formula =INDEX(Mary!B9:E17...) but I wanted to write that 'Mary' or whatever sheet name to a cell in one sheet and sheet refenrence in this index-formula would change accordingly.

View 5 Replies View Related

Refer To The Cell In Dynamic Range

Oct 4, 2011

I want to know all times this one presents the number 3 in the last 10 cells of the A column

For a static range I use this function


If I add a new cell which is the function for a dynamic range?

I can refer to the cell with this function = ADDRESS(MATCH(300;A:A);1)

but not as integrate it.

View 1 Replies View Related

Refer To A Cell And Pull Value AND Colour?

Feb 18, 2012

I have a cell containing a 'bullet' symbol (•) and a cell containing text.

If I make the bullet red and the text is black is there a way I can combine them in the same cell and the bullet remains red and the text black?

Essentially the situation Im in is I have a load of text I need to add coloured bullets to and I dont want to individually paste in and colour format all the bullet points because it would be too time consuming.

View 1 Replies View Related

How To Refer To Cell In Which Custom Function Is Used

Feb 8, 2013

Basically i want to use a UDF to count cells in a range of a certain colour.

But i want to make it easy for the user to be able to change the colour the function counts, so i thought i could ask them to colour the cell in which the function is written.

Is there a way to tell the function to pick up the Interior.ColorIndex of the cell it is written in?

Use Application.caller.interior.colorindex

View 2 Replies View Related

Refer A Macro Back To A Cell Value

Aug 31, 2007

macro which can paste the value from A1, to another B1 and when A1 is edited again, pasted it in B2. This will probably go on and on until B30. I have tried the if else then in Macro, and even the if elseif, but both don't go futher than B2. E.G A1=1 B1=1 A1=4 B2=4 A1=3 then nothing happens to B3. If there is a way to make this work, it will be great. The way i am tryin to get it is to have =if(B1="","",1) for each cell from C1:30 and with C31 the formula "=count(C1:C30)+1". Then i formated C31 to a custom and make it so that before numbers, there is an B. This means that if B1,2,3 and 4 and numbers in them, then C31 will read B5. That will be the cell i want my next record to go. I would prefer it if there is just a code that i can enter that will go to the next cell when it knows the current cell has a digit in it but if i have to, the count way will do,

View 9 Replies View Related

Too Many If Statements: Refer To A Cell And Use The Value Of That Cell To Print The Range

Aug 10, 2006

I use macros to print pages, depending on the number of entries I have. If I have 1500 entries, I have to have 1500 If statements. Is there a way to write VBA in a macro to where I can refer to a cell and use the value of that cell to print the range.

View 5 Replies View Related

Dynamically Refer To A Cell In A Macro Formula

Feb 17, 2009

I want to write a formula that inserts a column and then does a vlookup in that new column using the cell just to the left of it as the first variable. The problem is, this could be in any random column so I can't do a static reference to $A2 as an example. So, my question is...

Instead of using =vlookup($A2,Sheet1A1:B50,2,false)

How do I replace the $A2 part with some code that says, "the cell to the left of here..."

View 7 Replies View Related

Combo List Refer To Any Cell In The Worksheet

Mar 4, 2009

I need a list in my form, simple "Name/Number" list (only two options) but i don't want it to refer to any cell in the worksheet.
I want to input a text in a textbox and with the selection in the list above i want to have multiple choices at how to approach the text (if i input a name i want it to be different than if i input a number). All the info i came up on the web refers to lists made upon a range of cells.
How can i make a list without involving ranges of cells?

View 6 Replies View Related

Replace Folder URL String And Refer It To Cell

Oct 24, 2011

I'm using this macro to import txt files into excel.

Sub Bring_Articles_Into_The_File()
Dim sPath As String
Dim iRow As Long
Dim strString As String


Id like to replace the folder URL string ("C:Articles") and refer it to the cell "E5" instead. (So I don't have to open the code and change the folder every time)

View 3 Replies View Related

Sheet Name Stored In Cell - Refer To In Formula

May 31, 2006

Sheet names in Col B
B2 : Sheet1
B3 : Sheet2

I tried


at C3 where $J$58 is the cell I would like to reference on 50 different sheets

Formula returns #REF!
Col C ref's $J$58
Col D ref's $L$58
Col E ref's $N$58
Col F ref's $P$58

So as I copy the 4 formulas down, the ref to the correct sheet should update but the cell ref's should remain

View 2 Replies View Related

Refer Floating Text To Specific Cell In Worksheet?

Jan 20, 2012

Is it possible to refer a floating text to a specific cell in a worksheet?

View 3 Replies View Related

Use Cell Data To Refer Worksheet In Closed Workbook

Jan 29, 2010

At the moment, I have a project where everyone is putting work data on seperate workbooks. Each months work is placed onto another worksheet within that workbook.

The supervisor has his own workbook, that grabs data from each of the workers books. Getting the data is easy enough, however because the supervisor has barely any knowledge of computers, I would like to make it as easy to set up for future months.

Right now, data is collected in each cell using the following formula:-

='[otherusersworkbook.xls]December 2009'!$C$620

Is there a way of getting that phrase to substitute the part that says "December 2009" with whatever is put into column A on the same row?

View 3 Replies View Related

Refer Folder/Filename In VBA Code Through Named Cell Reference

Oct 31, 2008

I have the following codes in which I am to refer a file and folder to do some further processes.

myfilename = "C:Documents and settingsacsMy DocumentsEntrymyfile1.xls"
folderPath = "C:Documents and settingsacsMy DocumentsEntry"

I want to enter these two paths in a sheet in my excel report file (For example, I am running the report from Report1.xls, in which there is a sheet name "Filepaths". In this,

in B5, I would like to enter the Filepath (B5 named as "FILEPATH")
in B6, I would like to enter the Folderpath (B6 named as "FOLDERPATH")

So that, if I am copying the folder to another area, I no need to change the code every time in the VBA editor. I can do changes in these cells and it will be taken as the path to run the code further.

View 2 Replies View Related

Set Range Variable Using Variable Row Number

Mar 11, 2008

I am using a variable named " Totals" as a range type to refference the range in a formula. It works the way I have it.

Dim Totals As Range
Set Totals = [U37: AE37]

Now instead of the absolute refference, I would like to change the row refference by an offset of my current row, using a formula with a varriable. The columns stay the same.

View 3 Replies View Related

Combining Two Values In Two Separate Cells To Make A Cell Reference Or Index Refer.

Jul 15, 2009

I want to use a value in one cell as a row designation, and a value in another cell as a column designation. Ultimately, the values will be text which will refer to row and column headers. What formula would allow me to do this? example:

A1 contains B
B1 contains 2
B2 contains "tribbles"

An imaginary function might go like this........

View 3 Replies View Related

Find Same Values In Different And Unequal Cell Ranges And Refer To Values

Jul 2, 2009

I have data similar as shown in the following:


The idea is to add compare the cells of the first column with the third column. Where same letters/words exist, the corresponding value of the first column should be added to the second column (where no letter exists equally, the space remains empty), so it will look like this


the third column always will have at least the same letters as the first column, but new letters/entries can occur.

View 3 Replies View Related

Got A "Mid": Copy A Value To A Refer Contained Within Another Cell

Mar 4, 2009

I am trying to copy a value to a ref contained within another cell.

BF3 is where the formula is to copy
BJ1 contains the cell ref of "H6"
BI10 is the next cell to select

I think the problem is activecell = Mid(BJ1,1,5) which is the cell to which i want to paste the value. BJ1 contains the ref in text format of "H6" I am therefore trying to copy the value in BF3 to H6

View 4 Replies View Related

How To Get Row Number Of K Variable

Sep 25, 2012

I have find the maximum value from a range by using:

k = Worksheetfunction.max(range("c5"c25")
where k is a variable

Now I want syntax to get the row number of k variable.

View 4 Replies View Related

Variable For Row Number

Apr 13, 2014

I write a function like below

Function ABC()
dim row as long
row=???(how should I input?)
end Function.

the formula in "A3" cell is ABC()

When the ABC() run, How to let the function ABC know the row? (answer is 3)

View 10 Replies View Related

Use Last Row Number As Variable?

Jan 20, 2013

In my spreadsheet I have around 30 macros... and the majority of these macros make reference to the last row of a worksheet (in my case the last row happens to be 4867). There are some 50 or so references to this last row (albeit in different columns such as '$A2:$A4867' or '$CQ2:$CQ$4867' but in any case, this number '4867' occurs rather a lot.

The last row number only ever changes when I add more rows to the spreadsheet every 3 months or so, and when I do this, I just simply go through each macro carefully and Ctrl+F and replace all mentions of '4867' with whatever the new last row number is. I want to make this a little more efficient by using a name such as 'MyLastRow' and use that in all the macros and formulas so whenever I add new rows to the sheet, I just need to type the new row number in one place, and all the macros will adjust themselves accordingly.

I have tried defining a name for the last row (calling it 'MyLastRow' and giving it a value of '4867' but I cant make it work in formulas even simple ones such as =SUM($A$2:$A"MyLastRow"). I think Im on the right track, but am struggling to find resources and good examples to guide me....

My spreadsheet is extremely large (621 columns x 4867 rows), so I am looking for a very efficient way to do this using non-volatile functions and not using named ranges as I understand these can slow down performance as they use the volatile OFFSET function... and besides, with 621 columns, I do not wish to have 621 defined names!

View 9 Replies View Related

Use Variable For Row Number

Aug 29, 2006

how can i assign the refrence to the rowa using variable. I am getting an error due to line Rows("j:k").Select in the below mentioned code

For j = 2 To 2000 Step 2
k = j + 2
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Next j

View 6 Replies View Related

Sum A Variable Number Of Cells

May 1, 2009

I would like to have a cell in A2 sum up the values in cells A1, B1, C1 where the number of cells it sums is a variable in another cell that may change. I would like the same to apply to cell B2, C2, D2, etc.

This may make more sense if you look at the attachment.

View 11 Replies View Related

Sum Of Variable Number Of Rows

Aug 7, 2009

I reckon this should be easier than I'm finding it, but I just can't seem to find the right combination of functions to solve this. In column A I will have an entry every 5 or 6 or 7 rows with blanks rows between. In Column B starting at every row corresponding with an entry in Column A there will be a short column of figures could be 1 2 3 or four or more of them. (the're will always be a blank between the last number in a group in B before the next entry in A). In column C starting at every Row corresponding to an entry in column A I want the sum of the group of figures in Column B.

But here's the rub.... The most important thing is that I can use the same formula all the way down column C. So click the one formula at the top and drag it all the way down 1000 rows.

View 4 Replies View Related

Display Variable Name Not Number?

Feb 27, 2013

I am creating a very simple budget report for a tournament I am hosting. I want to specify whether payment was from Check or Paypal and want each one to resemble a value. This is because PayPal takes a service fee and when we get a 50$ payment it is actually 48.25$. So basically I have 4 columns for the revenue side of the budget report. The school that is registering, Payment type, Number of participants being sent, and total payment received from the school.

My hope is I can have Payment Type*# of participants to equal total payment, but not have a number being displayed for payment type. I would prefer to have payment type say PayPal or Check or at least P and C instead of 48.25 and 50 respectfully. I found a way to insert a name for a value, but when i type =PayPal the value of 48.25 comes up and i cant find a way to format the cells to display PayPal and have it just represent 48.25.

View 3 Replies View Related

Storing Number As Variable?

Jul 10, 2013

My code needs to find the last date listed in column A, which it already can do. And calculate how many days have passed between today and that date it finds in the column. Which I think my code can already do.

How do I store the number for later use?

Meaning, the next part of this code is going to send a request to a website to retrieve however many days of data that number is to be above ^. So it might be 2 days, 12 days 7 days, who knows...but the http request part will come after.


Sub date()
Dim lngLastRow As Long, lngRow As Long
Dim strColumn As String
strColumn = "A"
With ActiveSheet
lngLastRow = .Cells(.Rows.Count, strColumn).End(xlUp).Row
For lngRow = 2 To lngLastRow


View 4 Replies View Related

Variable Row Number Macro

Jan 2, 2007

This works: row(x).select But this doesn't: row(x:"100").select. I also need to do substitute both beginning and end range with a variable: row(x:n).select And multiple ranges: row(x:n, a:b)

I've tried tried numerous combinations of quote marks and parentheses and nothing works. What is the proper syntax?

View 5 Replies View Related

Select Row Using Variable Row Number

Apr 17, 2008

I don't know how to concatenate a string within the Rows function. I want to be able to vary the row number with a variable, but I don't know how to construct the string, especially given that one of the delimiters within the function is ".

View 3 Replies View Related

Splitting Range To Variable Number?

Jun 26, 2014

I have to split a range (with a variable number of rows and a fixed number of columns) to a variable number of persons (stated in a column from another worksheet). Basically, in Sheet1 I have in column B a list of names (for example: B3="A", B4="B", B5="C"). Can be a list of 3 names, 4 names or any number of names.

In Sheet2 I have a range of data which has 12 columns and a variable number of rows.

Now, I want to divide equally the rows from Sheet2 to the names from Sheet1.Column B, by creating a new WorkSheet for every name.

For example: If I have 3 names and in Sheet2 a range of data with 10 rows and 12 columns, I want to create 3 new WorkSheets (one for every name) and in every WorkSheet I want to have an equal number of rows, as following:

Sheet Name1: rows 1-4
Sheet Name2: rows 5-7
Sheet Name3: rows 8-10

By this way I splitted the list equally to the 3 names and the first name receives an extra row because 10 Mod 3 is 1, therefore remains a row undistributed.

View 2 Replies View Related

Copyrights 2005-15, All rights reserved