I want to apply some logic to a range. However I want to offset the bottom of the range by 1 row.
Example: I have a range (B8:I19) already defined in my vba code. But I want to shade range (B8:I20).
MyRange = Range("B8:B19")
This code also offsets the top of the range (row 9), which I don't want.
How can I only offest the bottom of the range?
View Complete Thread with Replies
Related Forum Messages:
Set Range And Offset
I am having trouble with one line of this code that I can't figure out how to write correctly. I have set the range, but I need to offset by 10 rows up. My code fails at set rng.
I am currently writing some VBA code to loop through and copy data from Excel file in sub folders into a master sheet of data. There are some 1200 Excel files (these are pre-2007 files), each containing a maximum of 600 lines of data. So far the code works until it gets to around 65000 rows (the old Excel limit). I am using and writing the code in a Macro-Enabled Excel 2007 file.
I am using a Range.Offset call, which is where the error is occurring, to copy in a name basically. What happened right before this was a Range.Copy operation from the old Excel file to a Range.PastSpecial in the new one. This worked fine, and actually went a few hundred rows past the pre-Excel 2007 limit. But when the single cell operation Range.Offset().Value is called next, it crashes with a Application or User-Defined error. The code works some 100+ times through the loop with no problem, and the file that it was working on is no different then the other files.
Offset Range Value VBA
I have an offset range ("TheCell") that does not seem be working how I would expect.
I don't know if its because the sheet I am working on was originaly German but I would be surprised if that was the case.
I Use sheet change to set the peramiters of the range and to test the value
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
colcell = ActiveCell.Column
rowcell = ActiveCell.Row
ActiveWorkbook.Names.Add Name:="iname", RefersToR1C1:="=" & "Tabelle2!R1C" & colcell
ActiveWorkbook.Names.Add Name:="Jname", RefersToR1C1:="=" & "Tabelle2!R" & rowcell & "C2"
typeit = Range("TheCell").Value
but for some reason I am getting a runtime error 1004 worksheet failed.
I have used this technique before and its been fine so what mistake have I made :o)
Offset Range Naming
= OFFSET(CustomerInfo!$A$9,0,0, COUNTA(CustomerInfo!A:A),1)
for a "dynamic" range name...i like the concept, but my data validation in a cell that references this "dynamic" range name (with the offset function) doesn't recognize all the values in the range
(when i just range name it, the data validation sees all the names, but not all when i use the offset...)
Alternative To Offset() In Named Range
I have used Offset() for creating dynamic Named Ranges in Excel 2003. I'm a little disturbed that this usage is no longer supported in Excel 2007? Has anyone else seen this breakdown? What alternatives are available.
In my brief investigation, it looks like opening the .xls in compatibility mode allows the usage to work. However, saving the workbook as a .xlsm (since I also have macros in it) causes any usage of the named range containing Offset() to return an error (both VBA and sheet functions).
Dynamic Named Range Without Offset()
When I make a dynamic named range, I typically do something like:
I remember awhile ago I saw (within some of the comments on Jon Peltier's site, I believe) a way to make a dynamic named range without using offset. Does anyone know how to do it?
Combining If, Offset And Range Of Cells
i need to get an equation correct for a scheduling application
assume $f24 is a task frequency and U24 is our current cell location
i am asking if (the range of cells to the left of current cells (range being task frequency -1 columns wide) are empty - and if so - put an x - if they are not empty - then leave it balnk.
i can get it to to work for a 2 weekly schdule but need it to work upto 52 weeks
i have a simple spreadsheet with the problem clearly defined for anyone who can help
- beer in it for anyone who can help - or can pay via paypal if required
Range Offset Error 1004
I am using the following macro to format a sheet - I recently added a auto-fill part to it which essentially moves a number from one column to another and autofills it in all the cells until it encounters another number of the same kind in the column it moved the previous number from.
When I try to run this macro it does everything upto the auto-fill part and then gives me error 1004 [the set cell = cell.offset(1,0) ] is highlighted in yellow.
Sumif With Offset Date Range
I am trying to sum multiple columns of data by a sumif based on a criteria in column C, the columns are weekly dated, and I wish to match columns by offset this initial column with a start date and end date and sum columns in between, I have been getting close but only returns one columns values?
FilterCol is column for criteria match
Start Col is name range - OFFSET(FilterCol,0,'Summary totals line groups'!$G$4,1,1) - End col similar, (G4 is a match date to find column ref)
Offset For Specific Cell Range(s)
I am designing a form that tracks call times. I have a control "cmdStart" that when clicked will enter the "Start" time in cell A4 and each time clicked will skip a column and enter the next time in cell C4. The same for a control "cmdEnd" that will enter the "End" time in cell B4 when clicked. Then the next end time clicked will go in cell D4. However, when the Start time enters the time in AE4 I need the next start time to start in A6 and do the same in this row until AE6 and then drop down again. The same with the "End" time when it reaches AF6. I think I could write the If and Else for each individual cell, but there must be a more efficient way to do this.
Dynamic Range Using Offset And CountIF
I have a data set that alters each week which means at the moment I have to update the ranges manually each time. I would like to use a dynamic range and think I need to use the Offset and CountIf functions. Both the start and end of the ranges are dynamic. The range is based on grouping the numbers in Column E (LocNo)
What I would like to do or think the way to achieve this is by:
First looking at Column E
Count how many cells are equal to criteria. (CountIf)
offset 5 columns left from the first cell that meets the criteria (Offset -5)
offset X rows down based on how many cells meet the criteria (Offset X)
I've include a spreadsheet spread sheet which 'should' help illustrate the problem showing the ranges I would like and how the data changes each week.
ActiveCell.Offset - Copy Range
Can i convert this
ActiveCell. Offset(-1, 0).Copy
.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
So that i can copy/paste the Offset range such as (-1,-2) (-1,1)?
Dynamic Range - OFFSET Function??
I want to use a dynamic range in order to use this formula below in column A as long as there is something entered in column H = SUMIF($N:$N,A5,$I:$I). any ideas on syntax and will this be using the offset function within excel. I know I have posted a couple times about getting this formula to replicate itself down certain columns as long as someone enters text in another. I looked into the offset reply information somone posted but it seemed a little over my head.
Offset X Rows Of Last Row In Range
given a range named xyz which refers to d1:e3
where the 3rd row is blank. I want to examine the row after the range with
I find that this code refers to the last row of the range which is blank. How can I be sure that I will be 1 row (offset=1) below the range?
Color Offset Of Named Range
I've created a named range "Row_16" H16:M16. I've made a macro which colors the interior of this range..
.ColorIndex = 48
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
I would also like to add a secondary color (Red) to the row just below this range ie H17:M17. Is there a way to offset/ select an entire range.?
Select Range Using Offset With Variables
I am trying to select a range in VBA, where I know the name of the starting cell, and the size of the range are values returned earlier in the VBA function. I guess the pseudocode I am trying to do is: range(range("StartCell"):range("StartCell").Offset(x,y)).Select. Obviously this code doesn't work, but I don't know the correct way to select this range
Return Range. Offset From Start Point
I need help in simulating the functionality of the OFFSET function with some of standard Excel functions which are shown at this webpage (I will be using this converter to generate the webpage from the sheet):
Spreadsheet Converter Supported Functions
I ask this because I need to create an interactive online calculator which absolutely needs to have the ability to allow the user to select the RANGE of the data to be analyzed. I included an example sheet with the offset function in the pink cell…Do you think any other standard excel function can be used to simulate its functionality?
Cant Get A Range(activecell.offset) Statement To Work
I have a combobox which is linked to a list of policies which has information to the right of them, upon changing the value in the combobox the subroutine below is activated.
It stores the value of the combobox in a string variable, goes to the list and searches for the cell containing the policy. Upon finding the cell it uses the range offset operation to select the two boxes to the right of the active cell. This is where I get my error 1004 - application or object defined error.
Private Sub cmbSectionName_Change()
Dim mySearch As String
'Assigns combobox contents to mysearch
mySearch = cmbSectionName.Value
'select the range
Vlookup In Macro With Variable Offset Range
The message shows me "Can not get the vlookup property of worksheetfunction class" and don't know the reason. The 'plancomm' and 'bonus' is the range name in different worksheets of the same workbook as the rngcell.
.Offset(0, 1).Value = WorksheetFunction.VLookup(rngCell.Offset(0, -3), Range("plancomm"), 2, 0)
.Offset(0, 2).Value = WorksheetFunction.VLookup(rngCell.Offset(0, -4) & rngCell.Offset(0, 1), Range("bonus"), 6, 0)
Offset Cell From Found Maximum In Range
I recently asked how to locate a max value within a variable range using a macro and got the following responses: Get Maximum Value From Graph / Chart, all of which worked great.
Dim r As Range
Set r = Range("D2", Range("D50"))
Range("K1").Value = Application.WorksheetFunction.Max(r)
Range("Max1") = Application.WorksheetFunction.Max(ActiveChart.SeriesCollection(1).Values)
Start = "D24"
Finish = "D163"
myrange = Selection.Address
Range("Max2") = Application.WorksheetFunction.Max(Selection)
Now I would like for a different cell to return the time value located one column to the left of the max value found above. I've tried to adapt other offset formulas that I've found to my purposes and haven't been able to make it work. how to do that using the max value as it is found in any of the above three ways
Copy Range Of Cells - Returned Address To Some Offset
Dim FoundCell As Range
Dim SearchString As Variant
'Specify Value to Search
SearchString = " Excel"
'Perform the Search and Return a Cell Value
Set FoundCell = Worksheets("Source").Range("A1:A10000").Find(" Excel", lookat:=xlPart)
If Not FoundCell Is Nothing Then
MsgBox "Found at " & FoundCell.Address
I'd like to take the code above, which returns a cell address which contains the text " Excel" and modify or add to it the capability to copy a range starting from the address returned and ending 102 cells further down in Column A on the Source sheet to A1 of the Sheet1 sheet. The crux of the problem seems to be converting the address to a row number then adding the value of the number of cells in the range to find the end row number then converting that back to an address??
Add VLOOKUP To Cell (Macro Code) & Offset From Range For Lookup Value
I'm trying to use an offset from a Named Range as my source cell in a vlookup but get a -1004 Object not defined error. When Debugged the Range.Formula appears to be blank when queried. Using Record a Macro the Reference to a named range worked fine but I could not test for an offset or the use of the range reference. What can I do to use to make this work
Range Name And Range Offset
What I have is a 3 sheet workbook that I want to use as a schedule: 2006,2007,2008. Each sheet consists of many ranges the first range on the 2006 sheet is named fri_July_7 and includes rows 8 to 73. All ranges are named with consecutive dates in this format (someone else on the forum helped me do this) Yes, each range is 65 rows (colum A lists 7AM to 11PM in 15 minute intervals for every day all the way down the sheets). the range name box lists all ranges in alphabeticle order for all 3 sheets, no big deal... I set up a control panel (form) that appears at startup on top of the top 8 blank rows. the active sheet can be used while the user form is active via vbModeless, no problem.
on this floating user form, I have two labels, and 5 buttons. the first label says "the selected day is", the label next to this is blank. The 5 buttons are lined up in a row and the middle one says "GO TO TODAY". The 2 buttons to the left of this say "GO TO LAST WEEK" and "GO TO YESTERDAY"...the other 2 buttons say "GO TO TOMORROW" and "GO TO NEXT WEEK". 1. How do I get the range that actually cooresponds to the real date to be activated and present at startup. 2. How do I have the blank label display a reformated range name (formatted like this "Thursday July 20 2006" for instance) that is determined by what ever the currently displayed range happens to be. 3. I know that the "GO TO TODAY" button will use the same code as the workbook code window that I will need for "1". How do I get the other buttons to jump x ranges ahead or back? I have searched for clues, and tried many things; scroll, offset, step methods... and have some clue, but I just can't seem to put it all together.
Find Last Cell In Range, And Changing Another Cell Based On Offset Text
If i have a range say E12:O12 and want to find the last cell before blank, lets say it finds m12 as the cell with the value before blank. then with m12 it needs to determine weather row 11 in the same column has Text either "S" or "F" if "S" then m12 = t if "F" then m12 offset(1,-1) = t. And just to make things more difficult i need the range E12:O12 to step 2 as well until it gets to E208:O208 .Noting that row 11 never changes and will always have either an "S" Or an "F"
and also t = time()
Check Each Cell In Range For Value & Put Text In Offset Cell
I'm trying to look at a value in one column (Column A) and if it matches a set of criteria, I'm trying to change the value of another cell 6 columns to the right.(Column G) I've been trying for a couple of days now to get this working, but to no avail. I've tried to modify the code below that I've found on this site but can't quite figure out what I'm doing wrong.
Dim FindWhat, rngCell As Range, i As Integer
FindWhat = Array("BB", "B", "CCC", "CC", "C", "CCC+")
For i = 0 To 3
For Each rngCell In Range("A2", Range("A" & Rows.Count).End(xlUp))
If InStr(rngCell, FindWhat(i)) <> 0 Then
rngCell.Offset(0, 6) = 0.15
To try to clarify a bit: If column A in the attached spreadsheet has a rating code of BB, B, CCC, CC, C, or CCC+, I want the Haircut % rate in column G to be 15%. It seems the code that I'm using changes the % rate to 15% if any "B" or "C" shows up in any part of the string in column A.
IF And OFFSET: How To OFFSET Only If Cell Has A Value In It
I have attached the .xls file.
The basic setup is as follows:
(1) the user inputs a number into cells B2:B6 (arbitrarily shown as 3,4,3 and 2)
(2) the user then inputs a series of values into the respective columns E, G, I or K (corresponding to examples A-D, respectively) with SPACING between each value corresponding to the value entered in B2:B6.
For example, the value "4" is chosen in B3, so values are entered in column G at time = 0,4,8,12,16,20....etc
As another example, the value "3" is chosen in B4, so values are entered into column I at time = 8,11,14,17,20,23...etc, ie. the starting point is not necessarily t = 0.
(3) once the values have been entered as described in point (2) above, a series of results are automatically calculated in columns F,H,J and L.
NOTE: I have omitted the formulae for the calculation and have just entered arbitrary (color coded for clarity only-i don't need color coding!) numbers alongside each inputted value for the 4 examples A-D.
OK, so what I want to extract from the table for each example is the paired time AND result values, and then show them in a new table.
I have used an OFFSET formula (originally suggested by "daddylonglegs") to do this, and the results i GET are shown in columns O-V.
HOWEVER, what i WANT is the output as shown in columns Y-AF.
So as you will notice, there are 2 problems:
(1) Example C in columns S/T: value in cell B4 = 3, but the first value entered in column I does not start at a multiple of 3, so no values are returned in columns S/T because the offset function only uses row 6 as a reference point. What i want is the result shown in columns AC/AD.
How do i write a formula which says, "look down a column, find the first cell that has a value in it, and then offset from that cell/row" ?
(2) Example D in columns U/V: since the first input in column K starts a t = 12 (ie, cell K18), then i have 5 rows of empty space in columns U/V. What i want is the result shown in columns AE/AF.
Lastly, i should add that i am not necessarily stuck on using OFFSET function, since i keep reading that it is quite volatile.
Private Sub OptionButton1_Click()
Set primary = Worksheets("Monitor Testing").Cells(20, 4)
For Counter = 1 To 3
If primary.Offset(0, 4)
I Looking for VBA code For the Below Cases:
Please Refer the below file.
Sheet1 *ABC1CatcityDate2Achennai12/10/20093Bmadurai12/10/20094Bthenai12/10/2009 Excel tables to the web >> Excel Jeanie HTML 4
If cat column states "A" i want to add Amount and value in sheet 3.
Sheet2 *ABCDEF1A *B*2Amountvalue*Amountvalue*31001*8001*42001*9002*53001*12002*64002*15002*75003*18005*86004****97005****108006**** Excel tables to the web >> Excel Jeanie HTML 4
Note : Every catgeory have chances to add Amount and value.(Example A cat Total count 8 but there is a chances to add or deleted 1 or 2 Row)
I'm trying to lookup a string in a column from another sheet and than return the row on which that string was found. I have two files, one in which my OFFSET/MATCH worked and another in which they didn't work properly.
My problem is this: I have multiple instances of a string in a column and i want to get all the info on that string (the rest of the columns). Let me explain in examples.
In column A on Sheet 2 i have
4 2 4
2 3 4
5 3 2
2 2 2
4 1 3
I need to have in Sheet 1:
4 2 4
4 1 3
Where the first 4 (bolded) is the reference value.
In sheet 1 i have a column A2 which is the reference. In column B2 i have
=MATCH(A2;'Sheet 2'!A1:A16051;1) - this worked on a file but returned a bad value on the other (donno why)
In the second file i used =MATCH(A2;'Sheet 2'!A2:A10552;0)+1 which returned the good value.
For the second value (row 4 1 3) i used =IF(OFFSET('Sheet 2'!A1;B2-2;0)=A2;OFFSET(Sheet 2'!A1;B2-2;0);0). This worked well on the first file but didn't work on the second.
I got the commands above from someone that used to update this file so i don't know exactly how they work
Using OFFSET In SUMIF
I want to use OFFSET in a SUMIF to define the sum range argument...
Essentially this is the OFFSET (simplified) =OFFSET(K108,-50,0,100) (which when I put a SUM around, works.
But, when I put it as the sum_criteria, I get a blank result. =SUMIF(OFFSET(I108,-50,0,100),I108,OFFSET(K108,-50,0,100))
What I want it to do is look at all the cells from 50 above I108 to 50 below I108, and sum the corresponding cells in colum K.
Offset And Resize
I have 3 workbooks, the first one contains the data and the second is the “Table1” containing "Normal records" and the third is the “Table 2” containing only "900 Records". Tables 1 and 2 will be linked to Access…..
Here’s my issue….
From workbook 1, I would like to copy data from certain cells that contain data to Table 1
From workbook 1, I would like to copy data from certain cells that contain 900 service records data to Table 2
In workbook 1, I have identified which information i want to keep by using the following formula,
Offset A Vlookup
i have a table with customers and the rentals they have made. in the table it has their customer number and then the item code of the item they have rented out.
i want to have a table that brings up the item codes of what they have rented but with a vlookup it only brings back the first item they have rented and not the ones after that.
I am trying to write code that will take values in a horizontal column (which are updated periodically) and transpose (copy vertically) them in another column. When the horizontal section is updated, I would like for the new data to be copied to the next open vertical line.
how to get this to offset to rows z9, z10, z11 etc....
Selection.PasteSpecial Paste:=xlPasteValues, Transpose:=True
OFFSET With Variables
I am trying to OFFSET from cell A1 based upon a variable in cell A2. The cell I need to OFFSET to is also located in column A, but it could always differ based upon the variable in A2. Here is the piece of code performing this OFFSET.
I am making a macro that takes the cell I have selected, extends the selection exactly 3 columns over, and then autofill extends the formulas 3 rows down.
So far I have:
Selection.autofill Destination:=Range(Offset(0, 3)), Type:=xlFillDefault
The range(offset(0,3)) in the destination doesn't work. What am I doing incorrectly?
I have this formula (part of a block covering 4 columns) in cell D12.
Every month this bock of information has to be copied across 4 columns i.e.
D:G is copied to H:K then H:K to L:O and so on.
When I do this the calculation needs to change as follows -
Month 1 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!B14)
Month 2 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!C14)
Month 3 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!D14)
Because I am copying across 4 columns this happens
Month 1 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!F14)
Month 2 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!J14)
Month 3 D11*AVERAGE(DATA_2006!$A$14:DATA_2006!N14)
Cannot Gain Value Using Offset
I have a rather details and complicated procedure that in effect is designed to find a value (>=) than a text box value inputed.
There are 2 other list boxes (5 & 6) that are also designed to narrow down the search.
The values available in list box 5 are a customers name in column C.
(Sample sheet highlighted value in Yellow)
The values available in list box6 are a product type.
(Sample sheet highlighted in blue)
When i select a value in list box5 and in listbox6, i enter a numerical value into text box111.
I then click on a command button, to populate listbox3 with all found values in column C that are greater than or equal to the value in the text box.
Now comes the part i cannot seem to be able to do.
I need to be able to click on a selected value in list box 3, and find the value that is between 2-22 rows above it in column A and place this value in text box 4.
(List box 3 values are ONLY ever
I want to use the following command but with more to it:
I want to use this type of command to highlight an area...not just move rows/columns. I want it to highlight from a point on the sheet marked by X and Y and then down Z rows.
So if I'm in cell A1 and want to highight from A1 down to A10, I'm not sure how to write that part of the code.
I have a set of data
Col A, B, C
A = Date, B = Interval e.g 08:00, 08:30, C = Number
My aim is to lookup to A+B in order to retrieve C
I have tried and offset within a lookup and upto now have been unable to proceed, I have attached the formulae I was using;
=HLOOKUP($I$4,Sheet2!$A$5:$A$6,OFFSET(B5,MATCH(H5,Sheet2!$B$5:$B$6,0)*0,1),FALSE) - returns the date value