Find Last Cell In Range, And Changing Another Cell Based On Offset Text

May 4, 2009

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()

View 7 Replies


ADVERTISEMENT

Macro To Find A Cell Containing Text /select Range Offset / Cut And Paste To Lower Rows?

Feb 4, 2014

I am trying to find a macro that can search a sheet for any cell that contains the text "Not on AOI" selects a range that contains that cell, 81 rows below, and 2000 columns to the right, then cuts the selection and pastes it 162 rows below the original cell where the text was found. What's hard is that the number of columns between the "Not on AOI" cells is variable.

I'm very new to excel macros and the parts I think I've put together are:

Cells.Find("Not on AOI", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=True).Activate

[Code].....

View 1 Replies View Related

VBA - Find Cell Containing Text And Use An Offset Cell Value In Formula

Feb 13, 2014

I'm trying to do a column of individual discount calculations using a discount percentage found in a cell two to the right of a cell containing the text "Total SP:" that is always upwards and to the left of the cell where the formula goes (but could be two rows or could be 20). There are multiple "Total SP:" cells in the sheet - I always want the first one upwards. I have created the following but I get #NAME? where I hope to see the discounted value.

VB:

Dim Discount1 As Double
Discount = Cells.Find(What:="Total SP:", After:=ActiveCell, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=True).Offset(0, 2)
Range("R9:R" & LastRow).Formula = "=IF(J9>0,$E9*(1-Discount1),0)"

I've just thought, the Cells.Find needs to be redone for each cell where the formula is inserted to ensure it always catches the correct discount and this isn't going to do that - it's going to find it once and always use that single value.

I think this needs a Loop or something and to move the ActiveCell down one after the formula to get it to redo the Cells.Find.

View 1 Replies View Related

Excel 2010 :: Dynamic Range - Cell References Changing In OFFSET Function

Apr 12, 2012

I'm working in Excel 2010. I'm trying to create a dynamic range, using the OFFSET function. I've got it working beautifully but as soon as I save it and close the Name Manager the range stops working. When I go back into Name Manager I find all the cell references have changed (from C1:C600 to C1048572:C595 - or some other strange range).

P.S. What it's doing isn't so important as when the cell references are right it works. But just for full info: It's an OFFSET function, starting at A1. It will look at a list of companies and use a Match function to find out how many rows to offset (based on where the first instance of a particular company. And it uses the COUNTIF to make the range the same number of rows as there are entries for that company.

Here is my broken function:

=OFFSET('Map Point'!A1048572,MATCH("Company Name",'Sheet Name'!C1048572:C595)-COUNTIF('Sheet Name'!C1048572:C595,"Company Name"),0,COUNTIF('Sheet Name'!C1048572:C595,"Company Name"))

View 3 Replies View Related

Check Each Cell In Range For Value & Put Text In Offset Cell

Jun 7, 2008

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.

Sub RatingsFix1SP()
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
End If
Next rngCell
Next i
End Sub

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.

View 5 Replies View Related

Changing Text Color Based On Information In The Cell?

Nov 28, 2013

I have created a gradebook template so that I can keep track of my assignments as I get them and keep on top of my grades. Any way that I can code excel to work so that if my current average in the class ever drops below 70%, I want the color of the text to change to red to alert me that the grade is too low and needs to come up. I'm new to using VBA in excel and not sure how to do it or what to code.

View 8 Replies View Related

Changing Textbox Background Based On Other Cell Text

Jul 15, 2014

I wish for a text box (drawn Text Box, from the "Shapes" tab) to conditionally change its background color based on whether a cell in a different sheet says "Online" - in which case it should be green, or "Offline" - in which case it should be red. So far, the code that I have that doesnt work at all, which I'm not even sure where to place (I tried in the Workbook - Open?), is the following:

[Code] .....

I also need to do this for a total of 9 Text Boxes, if that changes anything.

View 6 Replies View Related

Changing Cell Colors For All Matching Textboxes Based On Text From Dropdown Menu

Feb 19, 2014

I have a large workbook, with multiple sheets. I would like to be able to select a name from a drop down menu, and have the cell color change for all entries of that name in my other sheets. I can do it manually, but it would be much cleaner and easier to have Excel do it for me. I have looked at other answers here on this forum and know that if it can be done,

View 1 Replies View Related

Changing Cell Text Color WITHOUT Using Conditional Formatting Based On Finding Keywords

May 29, 2012

I have a spreadsheet that uses VB macros to calculate sums of cells based on the font color of the numbers inside. It used to be fairly easy going through each cell and "classifying" them by color, so that my macros can go ahead and sum the numbers in each respective color's cell... but now I have a huge amount of numbers and would like to automate the process somewhat. Here's an example using the A and B columns:

flight $400
hotel $150
hotel $130
meal $20
meal $15
flight $350

I tried using conditional formatting to automatically change the color of the adjacent cells based on the presence of a keyword such as "flight" or "hotel", but this change is only cosmetic, and doesn't actually change the font color (it is still the default black, hence why my color-summing macros won't work!).

I'm including a sample macro for what I use to color-sum my cells, but what I am looking to automate the color-coding process based on looking for keywords as explained above in my example. Here is one of the working color-summing macros (for red, in this case) if you'd like to use it as a reference:

Function SumRed(SelectedCells As Range)
' Adds the values of the cells where the font colour is red(3).
Dim Cell As Object
Dim x As Double

[Code] ...........

View 9 Replies View Related

Find All Instances Of Cell In Column & Check Offset Cell

May 21, 2008

how to explain this except by showing it, so I explained it as best I could in the attachment. Anyone think they have a solution for this? Let me know if you need more information. Thanks!

the macro will look at the value I entered in cell A1, then find all instances of it in Column A
in every row that A1 matches, if the value in column E is "0", I need the macro to change the value in column E of that row from "0" to (that row's column B * $B$1)

View 7 Replies View Related

VBA - Change Data Source Of Pivot Table With Range Changing Based On Cell Value?

Mar 5, 2013

I have the following code to update a pivot table:

Code:
Dim pt As PivotTable
Application.EnableCancelKey = xlDisabled
For Each pt In ActiveWorkbook.Worksheets("sheet1").PivotTables
pt.ChangePivotCache ActiveWorkbook.PivotCaches.Create _
(SourceType:=xlDatabase, SourceData:="source!R4C1:R33443C55" _
, Version:=xlPivotTableVersion10)

Next pt

the R33443 term is what will be changing, the columns and the starting row should stay the same. is there a way to instead of using R33443, to enable the range to be changed based on a cell value?

View 2 Replies View Related

Changing The Background Of A Range Based On Text In The Range

Oct 20, 2008

I have been tasked with creating a scheduling system for my work. There are three groups of shifts that can be selected, Opens, Swings, and Closes. I have been asked to make the cells turn red if a user selects a sequence of shifts. We are trying to avoid having a person working three scenarios:

Close>Swing>Open
Close>Off>Open
Close>Open

If they select the shift that meet this scenario, then I need the cells to turn red. The complete list of shifts are on the "Data" tab and the the three scenarios have been inputted into the "Jan" tab in E13:G15.

I am using the code below to change the background of the cells in my worksheet based on what is in the cell. How can I modify it to accomplish the changes below and meet the criteria above?

View 12 Replies View Related

Find Text Within Cell Range Then Sum It Up

Jul 21, 2014

Type/Unit Sold

Car-A/20
Bike-A/5
Bike-B/20
Car-B/50
Car-C/100
Bike-C/100

I need a formula if it's Car then sum it up to 170 and for Bike is 125.

View 9 Replies View Related

Find Cell In Range Based On A Value

Mar 30, 2012

I have a sheet that has six sets of three columns on it. The columns are labels Ball #1, Number Times Drawn, Last Date Came Up. The first five "sets" are the same except the ball # changes from 1 to 2 to 3 to 4 to 5. The last set has columns labeled Mega Ball, Number Times Drawn, Date Last Came Up. Yes I am doing stats analysis on lottery numbers for a project.

What I want to find is the last date drawn for each of the numbers, 1-56, and have it go into the third column of the 3 column sets.

I will use the first column set for example. I have numbers down the first column A numbered from 1 to 56 (In series). In the next column B, I have the number of times drawn for each number, which I have working. In the last column of the set I want to have the Last Date Drawn.

I tried the following function (Formula):
=INDEX(Table1[Date],SUMPRODUCT(MAX((Item=A2)*ROW(Item)))-ROW(Table1[Date])+1)

This kind of worked. It returned a date but it was not correct. It actually said the same date for each number, which I know is wrong. I can't figure out where it is actually pulling that date from.

I should clarify that the drawing numbers are on a second sheet labeled "Mega_Millions_Numbers" in a table named Table1 and the Date column is A with a column label of Date. The table has column headings of Date, Ball#1, Ball#2, etc. through to Mega Ball column.

What I need is a function or formula to pull the last date drawn. I am NOT good in any way shape or form with VBA so if I can do this without VBA it would be best for me. I can follow along with formulas and functions well enough, just not VBA.

I will need to have this formula copied down 56 times per set and there are 5 sets so i will have to modify it for the other columns. (If your keeping track that totals 336 formulas).

View 1 Replies View Related

Find Text Based On Active Cell Contents

May 11, 2007

I have a workbook with 2 worksheets, A and B. Sheet A contains source data and sheet B a pivot table of this data. I want my user to click on a cell within the pivot table,click a button that runs a macro to find the instance of this value within Sheet A. I did record a macro but it did not work.

View 3 Replies View Related

Changing Cell Color Based On Changing Values

Sep 16, 2009

This may have been answered on here but can not seem to find it. My situation is I have values in A1,A2 & A3 that are like counter reading so the value is always changing. What I am looking to do is change the cell color if one of the values is over 500 from the other two values. Say A1 is 3000, A2 is 3250 and A3 is 3500. I would like the cell for A3 to change color.

View 2 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: 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

Find Value & Return Contents Of Offset Cell

Sep 3, 2006

On Sheet2 I have a table where I want M2 to do the following:

1.) Look at cell A2 where the name "John" is and B2 where the name "smith" is.

2.) Look at sheet1 and look in B2 and C2 for "John" and "smith"

3.) Once it matches the name, place the contents of sheet1, cell I2 into sheet2, cell M2.

So in short, match the name on sheet2 to the name on sheet1 and return the number in I2 to M2 on sheet2.

Maybe combining the persons name in to one column would make it easier?

View 9 Replies View Related

Find Value & Return Offset Cell Content

Nov 13, 2006

I would like to be able to find all cells in row 2 that are "greater than 0". Then I would like to return the coresponding job number in row 4. I need to create a list of each job with the number of hous spent on that job next to it. I may have 30 different jobs but only 5 jobs that have hours for the specific week.

How I attemted to solve this is to create a table that listed all the hours from the largest number in row 2 to the smallest. Then I found the job number corresponding to that number of hours. The problem with this meathod is that if two jobs have the same amount of hours then the first job number is returned for both values that are the same. See attached example.

View 5 Replies View Related

Find & Use Cell Address To Offset On Another Worksheet

Jul 27, 2007

I'm still getting to grips with the Find Command. Basically, I have the below code that looks at a line in a sheet(ws_Site) based on the Line ID Number that is in column A and then Finds that that LineID_Value in a different sheet(ws_main) and copies a value from column I on that line across. Problem is, if the cell I is blank it copies it across and essentially clears the cell if there was data in it.

How can I adjust the below code to only set ws_main.Range(c.Address).Offset(0, 8).Value = LineID_Value if LineID_Value is not blank?

For Each LineID In ws_Site.Range("A7:A" & SiteRows) ' Loop through all the cells in range

LineID_Value = LineID.Offset(0, 8).Value

'Dim c
With ws_main
Set c = .Range("A7:A3000").Find(LineID, LookIn:=xlValues)
'If Not c Is Nothing Then

ws_main.Range(c.Address).Offset(0, 8).Value = LineID_Value

'End If
End With

Next LineID

View 3 Replies View Related

Macro To Find Matching Text In A Range And Select Specific Cell

Oct 18, 2013

I have a client list in a table in my excel sheet. I currently enter the clients in a sheet that looks similar to a form. After the clients info is in this Form I have a button with a macro to copy the client info into a table on another sheet. This works perfectly.

Now I have another form that will retrieve the customers info in a click of a button in order to make changes to the client. Ei:I now have a second phone number and I want to update that client's info. What I want to do from here is take the info in Cell B2 (clients full Name), Do a vLookup in the "Saved Clients Table" in a Range within my table range. (Range: Saved Clients and the client's full name is in $A:$A and called "Clients Full Name" and once that name is found I need to select the cell in column C and the corresponding row.

This will allow me to copy the info in my form, Paste it in Transpose to the cell that is selected. (I already have that code)

Here are screenshots of what I am trying to accomplish. [URL] .......

View 3 Replies View Related

Loop To Find A Cell, Then Copy Offset Paste

Feb 1, 2009

I have a data sheet with employee information. Only one column. It prefixes information with codes, but keeps it in the same cell. I want to move data of certain types into their own columns, but the amount of data is variable, so I cannot simply move every Nth cell, etc.

i.e.

Employee#1
200 Firstname Lastname
204 99999999 (Employee ID)
G38 00005000 (i.e. Pension Deduction)
H38 00007580 (i.e. Benefits Deduction)
X96 00012099 (i.e. Staff Club Deduction)
Employee#2
200 Firstname Lastname
204 99999998
G38 00000775
X96 00001000

So you see some employees may have different codes altogether. But I know that I want all the cells that start with 200 to be offset (-1,1), and all the cells that start with 204 to be offset (-1,2), and so on so that basically I end up with columns of info instead of a one column list.

I have been reading and studying other peoples' macros, and am just starting to grasp the basic. When I wrote my own to accomplish this, I put this together, which doesn't work. But I don't know enough to know what I don't know.

View 7 Replies View Related

Offset With Automatically Find Active Cell With VLookup

Jul 30, 2012

I have 2 columns of data

column A = weeks (A2:A50) i.e. P1W1, P1W2, P1W3....P12W4 etc
column B = headcount (B2:B50) i.e. 5, 7, 5...10 etc

Essentially my criteria is "looking for last week and give me headcount" i.e. my lookup criteria is P7W5 ....however if P7W5 has no data, i want the lookup to go up or offset to the row above (it may be one to 4 rows above)....

View 3 Replies View Related

Find Date & Pass Offset Cell To Variable

Sep 20, 2007

How do I use VBA to send the value of a cell, for example, cell J77 to the variable "mastervalue1"?

I have a spreadsheet that has a column with dates ( in the format "mmm-yy") and next to it a column that has values. I want to pass the value of the cell that is next to the date cell that contains today's month to a variable in VBA. Auto Merged Post;here's an example of my spreadsheet

View 9 Replies View Related

Changing Cell Background Color In Another Sheet Based On Cell Value

Jun 13, 2013

I am working on a workbook with 200+ sheets and an index linking to each of the sheets. On the sheets there is a cell containing the results of calculations and I need the cell referencing the sheet in the index to change background colors depending if the calculations value is greater or less than 0. I currently have working code that also changes the tab color of each sheet depending on the value, but i am trying to add the index cell background change functionality into that. also, the index listings is subject to change. my working code is

VB:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("d34").Value < 0 Then
Me.Tab.ColorIndex = 3
ElseIf Range("D34").Value > 0 Then
Me.Tab.ColorIndex = 4
Else

[Code]...

and the code i am trying to get working is

VB:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngX As Range
Set myRange = Worksheets("Index").Range("A1:A500").Find(Range("C2").Text, lookat:=xlPart)
' the C2 is the reference the title that would be on the index
If Range("d40").Value < 0 Then

[Code]....

I keep getting the runtime error '1004: application-defined error or object-defined error the thing is, i ran the cell background changing code in a normal macro before integrating it in my other worksheet code first and it worked fine. I have a little code experience, though not much in vba and I am unsure what the issue is. if there is another better way to accomplish what I'm tring to do, that would also be fine.

View 4 Replies View Related

Macro: Changing Cell Color Based On Date In Cell

Jan 12, 2009

I did a search on this site and found some code I was looking for (see link:

http://www.excelforum.com/excel-prog...e-in-cell.html - Leith Ross's response code).

The code works perfectly, however, if I save the workbook with a different spreadsheet on top than the spreadsheet referred to in this code, I get an error message: Method 'Range' of object '_Worksheet' failed.

I should state that I did change "Private Sub Workbook_Open()" to "Private Sub Auto_Open()".

I assume I need to modify the code but am unsure as to how.

View 11 Replies View Related

Index Match Offset - Find Contents Of Reference Cell

Jun 21, 2012

How can I modify the following formula to find the contents of reference cell, for example if the cell reference (G$3) is equal to 9 I want it to use 8 instead.

Code:
IF(ISERROR(INDEX(tra!$E$2:$E$1100,MATCH(G$3,tra!$C$2:$C$1100,0))),"",
INDEX(tra!$E$2:$E$1100,MATCH(G$3,tra!$C$2:$C$1100,0)))

I tried using G$3-1 but this doesn't appear to work.

View 1 Replies View Related

Changing Cell Fill Colour Based On Another Cell Value

Oct 2, 2008

I have a table:......

I want to colour in the relevant cells for each ref depending on the numbers in the stage column. So for the first line, the cells in columns 1,2,4&6 need to be shaded in. For the second line, the cells in columns 1,2,3,4,&5 need to be shaded in. I already have a lot of conditional formatting set on the sheet so need to do this with a macro.

I have tried to write something but am having issues with it finding the 1 and shading in the correct column but then jumping out of the loop and on to the next cell.

View 4 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







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