Reference Cells & Ranges With Numeric Variables

Jun 13, 2008

I have the following macro, which works fine (extraneous code not shown)...

For I = Start_ROW To Last_ROW_Z
Range("A" & I & " : " & "O" & I).Copy

But I want to make the "O" column identifier dynamic. So I've defined the column with the dimension...

Last_COL_Tracking = Sheets(" Tracking").Range("IV" & Start_ROW).End(xlToLeft).Column - 1

But this returns a column number, not the letter, so I can't use it in my original formula.

I tried converting to R1C1 with the formula...

Range ("R[" & I & "]C[1]:R[" & I & "]C[" & Last_COL_Tracking & "]")

...but this errors out.

View 3 Replies


ADVERTISEMENT

Reference Cells Using Variables

Feb 4, 2008

I am having an error when I try to run it and it appears not to like my destination (line bolded) - WHAT AM I DOING WRONG.?? Numrows = Worksheets("File1"). Range("A65536").End(xlUp).Row 'get the Row count

' LOOKUP Looklist! (Col B)
'----------------------------
For d = 1 To 228
' looks in Looklist B2(2,2), check against G1(1,7)
If Worksheets("Looklist").Cells(d + 1, 2).Value = Worksheets("File1").Cells(1, d + 6).Value Then
' If matches then copies G-x(lastrow,7) to looklist L2(2,12)
Worksheets("File1").Cell(Numrows, d + 6).Copy _
Destination:=Worksheets("Looklist").Cells(d + 1, 12)
End If
Next d

View 4 Replies View Related

Reset All Numeric Variables During A Procedure?

Mar 19, 2009

Is there a way to reset all numeric variables to zero during a procedure (e.g. at the end of a loop), without having to manually set them all to zero within the code?

View 3 Replies View Related

Numeric Variables For Row & Column Numbers

Mar 2, 2008

I recorded a macro to perform a graphing operation which will be used in a For-Next Loop which will run eight times. I need to modify the “ range” portion of one of the recorded lines to allow the graphing data to be dependent on variables I have set up as integers. See the applicable part of the recorded code below.

Dim firstrowno As Integer
Dim ltcol As Integer
Dim lastrowno As Integer
Dim rtcol As Integer

‘code which sets the values of the above variables Is Not shown

ActiveChart.SetSourceData Source:= Sheets("PLOTS").Range("AN27:AQ33"), PlotBy _
:=xlColumns

How do I replace/modify the ("AN27:AQ33") in the code above using the variable integers; firstrowno, ltcol, lastrowno and rtcol ?

View 5 Replies View Related

Shading Cell Based On Ranges Of Numeric Data

Jul 10, 2014

How do you shade a cell based on multiple ranges of data? e.g. A value of...

1 shades red
2-3 shades orange
4-5 shades yellow
6 shades green

View 4 Replies View Related

Select Non Contiguous Ranges Via Macro, Using Variables

Apr 29, 2008

trying to select multiple ranges of data at once using variables as my selection range criteria.

I.e., I want something similar to:

Range("A10:A30,B10:B30,E10:E30").Select

But would like to be able to perform the same selection using variables.

StartVar = 10, EndVar = 30

I'm sure it's just a matter of syntax, but I can't seem to get it right.

View 3 Replies View Related

VBA Match Function With Variables / Number And Alternating Ranges

Jun 2, 2014

I am having a hard time getting my match functions to work with letters and numbers in the same range. I am also trying to figure out a way to have the ranges switch if there is an error. because the data is in multiple columns. It is hard to explain so I have attached a sample workbook.

ExampleFile.xlsm

View 13 Replies View Related

Absolute Reference Using Variables In Formula

Dec 1, 2006

I have written some VBA code that is functional, but yields a formula that is somewhat confusing to the user.

I have two string variables called TippityTop and Anchor, both of which refer to specific cell addresses in the R1C1 style.

I attempted to define other variables that reference cells that are offset from TippityTop and Anchor without using the ActiveCell route. Try as I might, I could not produce the cell addresses that I wanted these new variables to reference.

I consulted many Excel Help screens and referred to a book on Excel VBA, but I finally took another route.

I now have:

ActiveCell.FormulaR1C1 = _
"=IF(AND(ISNA(MATCH(RC[-2],OFFSET(" & TippityTop & ",1,-2):OFFSET(" & Anchor & ",-2,-2),0)>0),ROUND(RC[-1],2)0),""DOV not in Treasury"","""")"

The problem is that this code yields this formula in Excel:

=IF(AND(ISNA(MATCH(L587,OFFSET($H$585,1,-2):OFFSET($H$798,-2,-2),0)>0),ROUND(M587,2)0),"DOV not in Treasury","")

Rather than OFFSET($H$585,1,-2):OFFSET($H$798,-2,-2), I would like the formula to say F586:F796, so that the end user can easily understand the logic.

View 9 Replies View Related

Reference Variables / Constants In Add-in From Workbook

Feb 21, 2008

I'm wondering if it is possible to declare a constant in an add in, and then reference that constant from workbooks that use that add in?

Basically I want to set a version number in the add in, and check it from the workbook.

View 3 Replies View Related

VBA Macro To Create Multiple Data Validation Lists From Variables & Named Ranges

Nov 10, 2008

I cant seem to find the correct syntax for creating 14 validation lists using array members as the source of the named ranged. The validation lists are stored on a different worksheet, the Named Ranges are created fine, as are the ranges that are having the validation applied. The Syntax I am having a problem with is

Public Sub assignDVList(WSD As Worksheet, sListName As String)
Dim DVListName As String
DVListName = "DV" & sListName
Application.Goto Reference:=sListName
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=" & DVListName

It is the Formula1:="=" & DVListName that is creating the headache. The sub is called as the array moves through the columns, using the header row as the Name for the Named Range, and the data Validation worksheet uses the same naming except it has DV in front.

View 4 Replies View Related

Add Vlookup, With Variables, To Cell To Reference Another Workbook Via Macro Code

May 21, 2008

I am trying to use VB to vlookup between to workbooks
1. Make active workbook WBK1
2. Make workbook being open WBK2
3. Copy and Paste between WBK1 and WBK2
4. Have a vlookup in WBK1 and bring in the values from WBK2
5. Close WKB2
6. Copy, Paste, and transpose values in wkb1 within wkb1

The script works fine until it reaches the vlookup step. I have used the vlookup by itself without the copy and paste code successfully but when I combine the two it provides me with the error 9. Subscript out of range.

View 9 Replies View Related

Relative Reference NAME Ranges

Jun 19, 2008

Creating a named range relative to the active cell? So that I can click on any cell and a named range is created in the adjacent column for 5 rows.

e.g. click cell c5, and a named range from cells d5:d10 is created when i run the macro ...

View 9 Replies View Related

Cell Reference- Able To Reference Two Cells To The Left Even As More Cells Are Added

Jun 11, 2008

I have 5 columns set up: A,B,C,D,E
D is the sum of A and B
E is the sum of A,B,and C

As I add in a new column to the right of C (call it C2), I need D (which has shifted over one) to sum A,B, and C.

I also need E (which has also shifted over one) to sum A,B,C, and C2.

Essentially I need a function in a cell that will be able to reference two cells to the left even as more cells are added.

View 9 Replies View Related

Using Named Ranges Following Indirect Reference?

Feb 7, 2012

I have the following formula which i'm using to indirectly reference a worksheet. The worksheet i'm referencing includes named ranges that i'd like to call on but i can't get the syntax right.

Code:
=SUMPRODUCT(--(INDIRECT("'"&HH_Elec_Title&"'!B15:B19")>=D5),--(INDIRECT("'"&HH_Elec_Title&"'!B15:B19")

View 6 Replies View Related

Named Ranges Reference Change?

Nov 27, 2012

Change "refer to" in Named Range. I have a named range myrange referring to A1:A5. I have a condition for B1, if B1= annual then myrange should refer to C1:C5 and not A1:A5..

View 2 Replies View Related

Identify Circular Reference (Changing Ranges, Vlookup(), If() And Sum())

May 28, 2007

Changing Ranges, Vlookup(), If() And Sum()

This is the link to the thread where ByTheCringe2 showed me the power of SUMPRODUCT and sorted my problem out. I don't think you'll need it, but I'd rather reference it before Roy reprimands me! lol

I am building on the same topic, though.

Hi All!

I have an investment where the monthly interest is added back to the capital. The next month earns interest on the higher figure and this higher interest is again added onto the capital and the story starts all over at the next month. OK, that's easy to do (Again, I think!).

All works fine UNTIL the end of the Tax year is reached and Tax on the interest earned is payable from the investment as the capital carried forward is reduced by the Tax payable. In the attached file I show how I calculate the interest earned for each following Tax year (which always ends at month 2) using SUMPRODUCT. Sumproduct is used because I never know whether the initial investment is made in month 5, 11, or any other month and by using certain controls (thanks ByTheCringe2!) I can simply total the interest earned in each tax year - the months between month 3 (start) and 2 (end).

On a seperate sheet I calculate the Income Tax payable as follows:

Firstly, I calculate the standard Tax payable on the investor's income from other sources. I then add the taxable portion of the interest to the standard income from other sources and calculate the tax payable on that combined figure. I then deduct the two figures from each other and get the increase in Tax payable because of the interest earned.

This "increase in Tax payable"-figure is then returned to the spreadsheet on which the interest is added onto the capital. See Sheet2! cells O9:O15. The Tax payable for each Tax year is placed next to taxable values I calculate using SUMPRODUCT (again!) in column N9:N15.

VLOOKUP is then used to transfer this Tax payable figure into the calculations (Column K9:K68) as and when required (only when tax is payable) - and should be deducted from the value in (Same row) Column H and that answer should be transferred to next row Column E (Balance at beginning of month) -

BUT it causes CIRCULAR REFERENCE faults and I am absolutely frustrated at not being able to figure out how to sort it out!

Sheet2, Column E9:E69 (See Sheet2!E19 for Comment explanation) in the attached workbook.

View 9 Replies View Related

Cascading Ranges - Vlookup (make My Reference Range Access Multiple Columns)

Feb 10, 2010

I need to run a vlookup to find some data. But I have a lot of data about 600,000 lines. Currently this list is spread over several columns (as the limit is something like 50000). How can I make my reference range access multiple columns?

View 5 Replies View Related

Cell Reference :: Formula To Reference New Cells

Feb 15, 2010

I have lets say 12 months of data. I have formulas that reference the latest 6 months. When I insert a new column to input a new month, how can I make the formulas include the new months without manually updating them.

EXAMPLE:

12 months of data exist in cells B3:M3 going from B3(oldest) to M3(newest). Formulas reference latest 6 months of data in cells H3:M3. When a new month hits, I insert a column after column M.I would like the formulas to now reference cells I3:N3 which is now the newest 6 months.

View 14 Replies View Related

How To Reference Cells Value To Define Range Reference

Jul 14, 2014

Is it possible to reference a cells value to define a range reference?

[Code] ......

I am trying to define the row value in the range reference with a value in a secondary cell?

View 3 Replies View Related

Extracting A Numeric A Specific Numeric String From A Description Cell

Oct 22, 2009

I am trying to do is extract the volume size of products in 'ml'
from 10k plus products from a description field cell.
this description field could also contain the weight of the product in grams
so I cannot just do a search for a numeric string ,
it has to be associated with the milli-litres statement .

is is possible to do a sort of ' *ml ' search and then select and copy to another cell ???

View 9 Replies View Related

Calculating Non-Numeric Cells

Nov 11, 2008

I need to find the number of cells containing a specific word. Here's an example:

Site # Visit
1001 12-Aug-2008
1001 LATE
1002 08-Jul-2008
1003 09-Aug-2008
1004 LATE
1005 12-Aug-2008
1005 LATE

I need a formula that will calculate how many "LATE" cells there are.

View 3 Replies View Related

Restricting Cells To Numeric Only

Jan 26, 2007

I currently have an input screen where users copy and paste data from a seperate spreadsheet into a range of cells B11:B15 in the input screen.
A macro is assigned to then extract this data and paste into the recording sheets behind.

I would like to format somehow cells B11:B15 so that only numeric entries can be pasted in and not any alpha including #.

View 9 Replies View Related

Clear Cells In Range That Are Not Numeric

Mar 28, 2007

I am trying to write a macro in excel to clear all cells within a range that are non numeric. I seem to be going round in circles trying to find out how to do this.

I assume I have to use the IsNotNumeric(Target) argument but I can't find how to specify the target within a range.

View 9 Replies View Related

Check If Any Cells In Range Are Numeric

Nov 4, 2008

If I have the following cells and values

A1 = 0
A2 = 0
A3 = ""
A4 = 0

I want a vba if statement that makes A5 = "Numeric.

If I have:
A1 = 0
A2 = 0
A3 = A
A4 = 0

I want A5 to = "Non Numeric"

Similarly if:
A1 = ""
A2 = ""
A3 = ""
A4 = ""

I want a5 to = "Non Numeric"

Is there a way to do this without looping through each cell in the range?

View 9 Replies View Related

Condition: If Cells Content Is Not Numeric

Sep 27, 2006

I need to test a condition that at least one cell in the range (A1:A10) is not numeric. Is the syntax smth like: IsNumeric=False or smth like that? I cannot recall.

View 9 Replies View Related

Paste Formula To Numeric Cells Only

Oct 18, 2007

I am looking for macro to paste this formula: [abc.xls] Total BA def'!E12-'[NEW abc.xls]Total BA def'!E12. into any cell that contains a numerical value. the cell reference would change to correspond with each cell it is pasted into. just like it does in excel when absolutes are NOT used. If possible i would not want it to affect any cells that contain headers which would only have letters in them. If this is not possible it would still be worth having the macro replace everything with something in it and i could just replace the headers from an original file.

View 2 Replies View Related

Count Cells Between Numeric Range

Dec 29, 2007

I am trying to total the number of cells in a column that are 0 or greater but less than 365. I use countif for for a specific digit but cannot compute a conditional range using it. I need to count the number of positive digits btwn 0 and 365. The column is a computation of the difference btwn today and past and future dates. A plus digit means we missed sevice and better be ready for an angry customer.

View 3 Replies View Related

Color Cells Within Numeric Range

Jan 10, 2008

Trying to make an excel macro that changes the background of a cell dependant if the value is between one number and another or equal to another number.

Cell values =
a1 = 250
a2 = 475
a3 = 715

vba Example:

Case Is > 200 and < 400
colchoice = 4
Case Is >450 and < 550
colchoice = 5
Case is >600 and <700 or = 715
colchoice = 6
If i run the macro the cell background should be
a1 =4
a2 =5
a3 =6

View 4 Replies View Related

Clear Numeric Cells In Range

Jan 19, 2008

I am trying to code a command button to clear a range of cells if any of them contain a numeric value. For example. If any cells of cell range A1:C10 contain a numeric value then they would be cleared. Not all the cells in the range but only thouse contaiing numeric values. I have tried various methods with not-so-good results.

View 9 Replies View Related

Move Numeric Cells From X Columns

May 1, 2008

I have 2 large rows of data next to each other imported from a different programme. Some of the cells in these 2 rows consist of values, some consist of words. I only want to cut the cells with values in these rows and paste them in a new row, called TXid. I have written VB code that cuts all the data in the rows and pastes them onto the new row. Now I would like to cut only the values in the row. How do I select only the values in the cell?

Cells.Select
Cells.EntireColumn.AutoFit
Range("I1").Select
ActiveCell.FormulaR1C1 = "TXid"
Range("G3").Select
Do
If ActiveCell = IsNumber = True Then
Selection.Cut Selection.Offset(0, 2)
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell = ""
Range("H3").Select
Do
If ActiveCell = Isnumber = True Then
Selection.Cut Selection.Offset(0, 1)
Loop Until ActiveCell = ""

The ActiveCell = Isnumber = true is not working the way I want it to.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved