IF And OFFSET: How To OFFSET Only If Cell Has A Value In It

Oct 26, 2008

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.

View 7 Replies


Using OFFSET Function To Return The Value From Another Cell With Row And Column Offset

May 31, 2014

I am having some difficulties using a combination of IF and the OFFSET function to display a range of cell values from another column based on a simple condition. The values I need to display at the destination cells should be offset by 8 columns to the right and "X" rows down from the reference column. The value "X" is to be determined via the IF function to check for the row index number.

For example, if Index value "X" = 8, then display the value of B2 in cell I9. IF X = "9", display B2 in cell I10 etc.

I have attached a sample worksheet that provides some examples.

View 3 Replies View Related

Find Value, Offset & Return Offset To TextBox

Nov 1, 2006

- Find a value on a sheet “ORM” in Column G5:G33

-Get the corresponding value of B5:B33 of that cell

-Place that corresponding value in a canned remark: “You have the number 2 in Block, 12, 14, 25 22.

-Place this canned remark in TextBox31

View 9 Replies View Related

VBA Search / Replace With Offset 1 Column And Offset 2 Column

Mar 22, 2013

I am trying to work out how to nest offset in a code using search replace. The goal is to find a value from cell A1 (example) and replace the values in the cells next to the cell containing samuel and the cell containing samuel.

A sort of search and remove data tool if you like So for example:

[QUOTE]A1: "samuel" (the search criteria)
Search range is: B1:D400
(for example)
Cell B40 = samuel
C40 = Driver
D40 = year

So, the macro is activated and finds "samuel" in B40 and I would like C40 & D40 replaced with "" The code I'm using is below: (this is just replacing the cell containing the search criteria with "test". I would like to nest offset(0,2) & offset(0,3).Value = ""

Sub Macro1()
Selection.Replace What:=Sheets("Sheet1").Range("A1").Value, Replacement:="test", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
End Sub

View 2 Replies View Related

VBA Offset Cell Value

Mar 20, 2014

I'm using the code below to perform the following:

Compare a column of project end dates (column G on the "In Flight Projects" sheet) with the dates in a row of column headers, and Where there is a match, count the number of projects which are being worked within that given month.

[Code] .....

The code works fine, but I'm having a little difficulty in making an amendment to the code:

In the following section of code I need to select the Range ("G8"), but then say if the value in the cell, offset minus 4 has the value of "C&R" then run the rest of the script :

[Code] .....

I've made the following changes, but I'm unable to get this to extract the figure despite not receiving any error message:

[Code] ....

View 13 Replies View Related

Offset From Location Of Another Cell

Jan 15, 2014

Is there any way to use the offset formula in reference to the location of another cell?

Here is a simplified version of my problem:

Sheet1!A1 refers to Sheet2!A1.
Sheet1!B1 refers to Sheet2!D1.
Sheet1!C1 refers to Sheet2!E1.

Is there any way that I can say that Sheet1!A1=Sheet2!A1 and then use the offset formula based on the location referenced in Sheet1!A1? The cells being referenced are merged cells one column wide and varying rows long, so there is no real pattern to follow except that the corresponding cells (the ones that I want to use the offset formula on) are all taking up the same amount of rows and are an equal amount of columns over (Sheet1!B1 refers to 3 columns over from Sheet2!A1, Sheet1!B1 refers to 4 columns over from Sheet2!A1). The spreadsheet is a fairly complex one and it would be much cleaner and less likely to have any mistakes if I was not referencing each cell individually.

View 2 Replies View Related

Offset Cell Content VBA

May 29, 2014

I am looking for a vba to offset the cells.

The code I have currently is:

[Code] ........

This is only moving the selected cells across one, however - the content of the cells is what I wish to move so cell C25 has data pointing to another sheet cell A1 i.e. =Sheet1!$A$1 - can I edit this code so it alters the cell to reference B1, C1 etc....

View 14 Replies View Related

Cell Sum Offset Using Date

Dec 12, 2008

I am trying to determine a cell row thru which I want to sum a column based on date. For example, if today is in the month of December, the offset is row 87. When the month changes to Jan 09, the offset will be 88.

I have the formula which does this for me, but I am not sure how to use it in the sum formula. So if I want the sum for December, it would be =SUM(K18:K87) and Jan would be =SUM(K18:K88). Here's the wrong formula:


What I cannot get is how to properly format the formula so that the :KXX increments based on the formula. I tried this: =SUM(K18:K(ROUND((TODAY()-39783)/30.35+87,0)))
but get a NAME error.

View 2 Replies View Related

Cell Offset Within Macro

Aug 14, 2009

Cell offset within macro
I have a very basic macro controlled by a button as follows

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

Offset With A Cell Reference?

Oct 31, 2013

Is there a way to use the offset function with a cell reference for the first reference?

I have many columns of named ranges, each representing a month of financial statement data. I want to pull up certain cell values based on the months being compared.

For instance, if the user selects "May", I want to pull only the sales data for May 2013, May 2012 and May 2011. That data is in the 311 row of the columns for each individual month.


In short, I am using a vlookup to get the ytdmay2013 based on the chosen month of May in the input section. If the user then chooses June, the lookup will return ytdjun2013. I want to link the ytdjun2013 in the offset function.

View 8 Replies View Related

Select The Cell Via VBA / Offset

Nov 16, 2007

The Sheet below is an example of what I need to fill in daily

In column B I have the week commencing date (ie the Monday)

When the sheet is opened, I want the approriate day to be selected (ie the day before the current day)

Eg. if today is Friday 16th November, when the sheet is opened I want the cell for Sales on Thursday of the week which begins with 12/11/07 to be selected ie L5

If today is Monday 26th November i want Sales on Sunday of the week which begins with 19/11/07 to be selected ie U6 ....

View 9 Replies View Related

Active Cell And Offset

Nov 26, 2008

ThisWorkbook.Sheets(2).Cells(nrow + 1 + j, 2 + high_count).Formula = "=VAR(" & ActiveCell.Offset(0, n_high_count -1) & "," & ActiveCell.Offset(0, -1) & ")"
*n_high_count is the negative of high_count

I want "ThisWorkbook.Sheets(2).Cells(nrow + 1 + j, 2 + high_count)" to have the formula "=VAR(XX:XX)" where the range is the current row second column to the current row current column -1.

View 9 Replies View Related

Cell Count Offset

Dec 18, 2008

This is in regards to this script:

Set range = Sheets("VTOL").Cells(Rows.Count, "A").End(xlUp).Offset(1)
Loc = ws.Name & "!" & Range("O1").Address
ActiveSheet.Hyperlinks.Add Anchor:=range, Address:="", _
SubAddress:=Loc, TextToDisplay:=ws.Name

It adds sheets it finds starting at cell A2. But I actually want it to start at cell A3.

I'm drawing a blank here.

View 9 Replies View Related

If Column A Contains Ohio Then Offset By 3 Cell

Mar 17, 2014

I am looking to create a Macro that says: look at all of the data in column E:E and if you find a cell that has the word "Ohio" in the string of information, then offset that cell by 3 to the right and make that cell equal to "4"

Sub Test()

Dim rng As Range, cell As Range
Dim worksh As Worksheet
Set worksh = Worksheets("Axys Layout")
Set rng = Range("E:E")
For Each cell In rng
If InStr(1, cell, "Ohio", 1) Then
cell.Offset(, 3).Value = 4
End If
Next Ecell
End Sub

This is not working and I'm not even sure that I am on the right track!

View 4 Replies View Related

Find 1st Cell With Numeral, Then Offset.

Apr 21, 2008

How would I find the first cell in column A containing a number, like HY42128PP, and then offset 1 row up from there to start my autofilter?

Also, to copy the worksheet headings, what code would copy all rows from row 1, down to 2 rows above the first cell in column A containing numbers, and insert those rows in another sheet?

View 13 Replies View Related

Offset For Specific Cell Range(s)

Dec 18, 2008

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.

View 4 Replies View Related

Copy Target Cell To Offset

Oct 23, 2011

Copying the target cell to target.offset(0,-3)

View 5 Replies View Related

Summing Offset Cell References

Nov 8, 2011

I have code where the user inputs a date, the macro finds this cell and sets rngFound as the location of that cell. The macro then creates a new workbook with new worksheet. Using rngFound as a reference, I need to sum the cells one below and five to the right and put this sum into a cell on the new worksheet.

I did a little research and found the offset which takes care of the referencing, but I cannot figure out how to incorporate this into a sum function in vba.

Below is my attempt. Previous to this part of the code, I am active in the newly created worksheet so I am attempting to input a formula based on offsetting the found range. Another problem is that I am going to have to repeat this step for 50 rows going down. Is there a way to set a loop? Or would I have to write out this code, changing the ranges and offsets 50 times?

ActiveCell.Formula = Sum[(OrigWks.Range(rngfound.Offset(1,0))):(OrigWks.Range(rngfound.offset(1,4)))]

View 4 Replies View Related

Insert Picture Into Cell With Offset

Nov 22, 2013

I am inserting a picture into a cell and resizing it to fit the cell. The problem I am having is that the cell covers the border at the top of the cell. Is there a way I can offset the picture in the cell so it does not cover the border?

Sub Sig()
Dim filselect As String

ActiveSheet.Unprotect Password:="159357"
filselect = Application.GetOpenFilename( _
FileFilter:="Picture Files (*.png;*.jpg),*.png;*.jpg", _

[Code] ........

View 2 Replies View Related

Offset Cell To Populate The Text Box

Mar 11, 2008

How can I make this statement take the value from the Offset cell to populate the text box and not take the value from the text box to popluate the Offset Cell?

With txtBoarded
ActiveCell.Offset(0, 1) = .Value
End With
This code is in the user form initialize code.

View 9 Replies View Related

Offset Active Cell To Beginning Of Row

Jul 28, 2006

I need to make the active cell go to the beginning of the row (Column A). I tried setting up a variable to be the row.value, but that didn't work (the way I wrote it, which doesn't surprise me).

View 6 Replies View Related

Get Offset Cell Of Name Chosen In ListBox

Dec 16, 2007

I am wanting to be able to change the data in a spreadsheet cell(s) using a visual basic form. I've attached my spreadsheet file, so that you get a better idea of what I'm trying to do. What I want to be able to do is, on the VB form, to be able to click on the list box to choose a client, then choose the module number (option box) next to it which will then show the client's marks for that module in the textboxes at the bottom of the form. Then to be able to change the marks that student has for that module. I've given it a lot of thought, but I'm really stuck at this moment in time.

View 7 Replies View Related

Offset: Find The Last Value Cell In A Row And Display Its Contense

Jan 21, 2010

I need to find the last value cell in a row and display its contense. Is OFFSET the best way of doing it? Cell H3 will need to contain the formula and the row to seach is also row H. In H3 I want the value that is found in the right most cell on row H that contains anything.

View 3 Replies View Related

How To Copy From One Cell And Paste On Different Sheet With Offset

Nov 27, 2012

using VBA and most of what i know has come from reading through blogs. I'm trying to copy 5 separate pieces of data from one row on our Payroll sheet and paste this in to another sheet call master dump.

The issue that i am having is that the code i have written keeps coming up with a run time error 1004 at the line "a.Select"

What i need the code to do is this: Copy the data from cell A4 and paste this on to another worksheet in to row cell b2, date worked in to d2, pay code in ot f2, hours in to h2 and the cost centre in to ad. all on the same row. i then need it to move on to the next team member (in this case A5) and repeat until there is no emp#. once the monday is done it will need to move onto Tuesday.

Code below.

Sub payroll_data()
' Payroll_data_MON Macro
Dim a As Range, b As Range, c As Range, d As Range, e As Range, i As Range, j As Range, k As Range, l As Range, m As Range
Set a = Range("A4")
Set b = Range("I4")
Set c = Range("G4")
Set d = Range("H4")


View 9 Replies View Related

Offset Function - Get Text Form Cell

Nov 22, 2013

I have this offset function working:


The cell name "5260", is also entered as text in cell A1, in the current workbook (not calculos.xlsx). How do I refer excel to get the text from cell A1, instead of having to enter it manually.

View 3 Replies View Related

Lookup Value In Range Then Average Offset From That Cell

Mar 10, 2014

I have 2 columns of data (col A is time, col B is a value), in a range A4:B1000 (can be less, but the biggest the range will get is to B1000). Example:

A / B
4 10:37:55 / 91
5 10:37:56 / 92
6 10:37:57 / 93
7 10:37:58 / 100
8 10:37:59 / 105
9 10:38:00 / 110
10 10:38:01 / 111
11 10:38:02 / 115
12 10:38:03 / 120

Im looking for a way in VBA to look for a time entered in cell C1 (example 10:38:00), find that in column A, then return the average of values in column B that are offset 271 - 300 rows. This is entered in D1. So in my example, 10:38:00 is in cell A9, return the average of B280:B310.

View 3 Replies View Related

Change Color Of Offset Cell With Macro?

Jul 9, 2014

I am trying to color a cell with a macro. I am using

ActiveCell.Offset(a,b).Value= a number then a want to change the color of the cell to yellow. When I tried to code this, my Active cell's color is changed, but not the offset cell.

How do I change the color in an "offset cell".

View 5 Replies View Related

Offset Repeat Loop Until Empty Cell

Aug 14, 2008

I would like click in cell a6 and then click a button loaded with VBA code that would:

1. Offset over 2 and down 1 to c7 so that is the current cell
2. Repeat down until an empty cell is reached (our example will be c10)
3. Put the items found in c7, c8, c9 into a variable (is that right?)

Variable would then be used in a vba generated email that I have all ready to go. I would want each item placed in the email one after the other like:


View 9 Replies View Related

Using Currentcell.offset To Copy A Cell From Two Variables

Mar 5, 2010

I have a spreadsheet with 2 worksheets. I have a variable cell and a display cell on Worksheet A and two other cells with information on Worksheet B that I need copied over to Worksheet A based on what is entered for the variable on Worksheet A.

I want to be able to enter a variable in Worksheet A, cell B25. I then want the code to look up the variable I just entered at B25 on Worksheet B, column A. Once the code finds the variable, then I want the code to copy what is in column B and enter it into Worksheet A cell C25.

In other terms, I want to enter "Bob" in Worsheet A, B25. On Worksheet B, I have 50 different names of people in column A and additional info directly to the right of their names in column B. When I enter "Bob", I want the code to find "Bob" on the Worksheet B and enter "is worthless" on Worksheet A, cell C25.

I have tried and got the code to work with several If/then statements and I accomplished the same using a select case arguement as well using something along the lines of "if B25="Bob" then C25=worksheet B("B2")" assuming Bob is in cell A2. My concern is the info on Worksheet B is fluid. I need to be able to sort and add additional lines at any given time. My data set is going to be between 500 and 800 rows. Any time I add a row and re-sort the data set, I want the code to find "Bob" in column A and then display what is in column B in Worksheet A, C25. I can continue to use the if/then statements, but they are static and if I add a new row near the top, I would have to re-number all the if/then statments in the code.

View 9 Replies View Related

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