Find Text/Value & Use Found Cell, Row, Column In Macro Code

May 10, 2008

I am trying to clean up and simplify my macros by compartmentalizing frequently repeated commands. I like to search for text in column headings and define the cell containing it as a range that I can later use .column or .row commands on, so my macros are a bit more flexible. The code I currently use for this is

Dim XColumn As Range ‘the cell containing the text “X”
Cells.Select
Selection.Find(What:="X", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Set XColumn = ActiveCell

I would like to be able to create a Macro (possibly name FindSetCell()) that will accept arguments and achieve the results of the above code in other macros
I think the command might look something like FindSetCell(“text to be searched for”,”name of newly Defined Range”) But I have not figured out how to code it

View 2 Replies


ADVERTISEMENT

Macro To Query Column For Date If Found Place Text In Cell

Aug 30, 2012

I am trying to make a macro that will query a column J4 for a date, if the date is found say "Wednesday, July 4, 2012" (J8) get the text from Column K8 "Independence Day" and insert the text in Cell (H1).

The Macro Prints sign in sheets with the date in H2, it only prints Monday through friday. Then skips the weekend and the next date will start the following Monday.

The Federal Holiday schedule is in column range J (Date) and K (Holiday)

This is where I am stuck ....

EmployeeTimeSheet_2012.xlsm

View 2 Replies View Related

Find Text & Offset By Found Value Row And Column

Apr 16, 2008

I'm writing some code where I need to know the column in which a specifc text string occurs. Because of the nature of the sheet, the string will only appear in one column, but that could be in almost any column on the worksheet.

For example say the text string is "Year 1", I need to find the column with this string, and then offset down to a predetermined row, or offset over to the appropriate column (something like below).

With Selection
.Offset(0, x).Select
If List.Selected(0) = True Then
y = i - 1
With Selection
.Value = Salary * Inflation1 ^ y
End With
Else

View 9 Replies View Related

VBA Code To Stop Macro If Specific Text Is Found

Feb 24, 2012

I have a simple macro that copies data from worksheet to another. I only want this macro to be run once per day by the user. One of the cells that gets copied is the value found in the formula "=today()". My thought is that the macro could look for the existance of the current date in the pasted data (meaning the macro has already been run once today), and if the date = today, then a message pops up warning the user that the macro has already been run once today, and ask if they're sure they want to continue.

Any easy way to accomplish what I'm attempting to do? The current date gets pasted into a worksheet name "PriorDay" in cell C5.

View 2 Replies View Related

Handle Find Macro Error When Text Is Not Found

Mar 1, 2008

I have the following macro which I've pieced together which works great at clearing the cell as long as the text entered by the user is found in the specified column.

Unfortunately I'm a big rookie with this stuff and I can't figure out how to handle the process/error when an entered value is not found. When ChosenRow returns with a 0 I get a Run time error '91', Object Variable or With Block variable not set.

The code...

Private Sub CommandButton1_Click()
oldSheet$ = ActiveSheet.Name
Dim ChosenRow As Long
Dim loc As Variant
Application. ScreenUpdating = False
With UserForm4
loc = .TextBox1.Text
End With
With ActiveWorkbook
Sheets("Reference").Select
End With

View 5 Replies View Related

Macro Code To Find Blank Cell In Column

May 30, 2008

Short and simple. What is the quickest, easiest & most efficient way to find the first blank cell within a column using VBA?

View 9 Replies View Related

Find Text, Go To Found Cell & Show Message If More Than 1 Occurrence

Oct 1, 2008

I have a file that the user selects and when they enter a value (in this case, a job title) into the input box, my macro looks for the value in that file. If the value is there, a msgbox pops up that lets the user know that the value was found and it then goes to that cell, displaying in the next msgbox the cell address of where the value was found. I already have the code down for this part of the macro.

My problem is what happens if the file has the same value more than once. Ideally, I'd like to display a message box that returns the addresses of both cells with the same value and then prompts the user to select one of these values as the value they are looking for. I am not sure if a msgbox or a msgbox and then an input box are most appropriate for this situation. Once the user does this, the macro continues. The rest of my macro is built on the cell where this value is, so it is crucial that I make sure there is at least one value selected. Any help is much appreciated. I have included a sample worksheet of what this situation might look like.

Here is the code I presently have for this part of my macro.

Sub GetOpenFileName()
strFind = InputBox("Please enter the job title you wish to search for:", "Search for job title in this file")

If strFind = vbNullString Then Exit Sub

With Sheets(strSheetsMainCompProfile)
If WorksheetFunction. CountIf(Range(Cells(1, 1), Cells(100, 100)), "*" & strFind & "*") = 0 Then
MsgBox strFind & " cannot be found on this sheet"
Else

View 9 Replies View Related

Looking To Find 1 Of 2 Words In A Cell In Column B And Return Word Found In The Same

May 27, 2014

Looking to find 1 of 2 words in a cell in column B and return the word found in the same row in column E. This seemed easy but I am not having any luck.

the cells in column B have several words in them but I am looking for 2 specific words "PLAT" and "ORIG". If the word is not in the cell, it should show a blank cell in column E in the same row, otherwise one of the 2 words should be in that row in column E. A VBA loop would be ideal but a formula that can do it might work as well.

View 3 Replies View Related

If Text Found In Cell Then Place A 1 In Another Column

Dec 21, 2009

What I would like to do is if a string e.g. "*12/18/09*" is found in column A, then place "1" in column B. There are many rows that I would like to search. Either a formula or VBA would be fine.

View 6 Replies View Related

Macro Code To Find / Insert And Fill Text?

Oct 11, 2011

I need a macro script that goes to a particular cell in a column based on a criteria (say, locate the first instance where $0.21 appears in col. H), insert a row above it, and fill the row with the text "Note:These are above $0.20"

View 2 Replies View Related

Find Text And Copy Found Range

May 15, 2007

I have some EXCEL files, titled as "AAA", "BBB", "CCC", so on... Calculated values are placed in Column Z for each file. In order for me to export the files to another software, I would need to create another new EXCEL file (I call it MASS) and place all the calculated values in that new file. In that new file, the titles have to be on Column A and the calculated values on Column B.

For example, File "AAA" has 120 calculated values. In MASS, the word "AAA" has to appear on Column A a number of 120 times and the 120 calculated values are then placed on Column B. Each value must correspond to the word "AAA". The same procedure goes for "BBB", in which the word "BBB" is placed on Column A after the end of "AAA". What I want to achieve is by using a macro that will look up the title of the Active Worksheet and then scan Column A in MASS. If the title matches whatever is in Column A, then the macro will paste the corresponding calculated values onto Column B automatically.

For example, for file "GGG", the macro will look up the word "GGG", scan through Column A in MASS for the start of the word "GGG" and paste the calculated values at the start of Column B. Could I have an idea of how might the macro looks like?

View 9 Replies View Related

VB / Macro Code For Multiple Find And Replace Within One Single Column?

Mar 17, 2014

code to find/replace the letters: "A" with "Active", "P" with "Contract", and "C" with "Settled sale", all in column "Q".

View 2 Replies View Related

Find Value On Row & Find Last Used Column Before Found Value

Mar 17, 2008

Dim ColNo As Byte
Dim LastCol As Byte

ColNo = Application.WorksheetFunction.Match("Column find", Range("sheet1!A1:Z1"), 0)
LastCol = Range("sheet1!b1").End(xlToRight).Column

But the below code errors?

Dim ColNo As Byte
Dim LastCol As Byte

ColNo = Application.WorksheetFunction.Match("Column find", Range("sheet1!A1:Z1"), 0)
LastCol = Range(Cells(1, ColNo)).End(xlToRight).Column

View 3 Replies View Related

Using Find In Macro Without Error If Nothing Found?

Feb 12, 2013

I'm trying to write some VBA which will allow me to find certain instances of data across a number of different sheets and copy this into another sheet.

However if the sheet doesn't contain the data I'm searching for an error pops up and the macro dies, is there a way to search where if the macro doesn't find anything it skips to the next line?

View 1 Replies View Related

Macro To Find Last Row In Column B And Text To Next Column

Sep 3, 2013

I have a macro that copies data from one sheet to another. I would like getting the macro to figure last row used in column B from B3 on and put the word Sum below it. For example, if last row used is B64, on B65 would like the word sum on it.

I cannot just input in as the number of rows could change when macro is run. Data is dynamic.

Here is simple code I have:

Sub Weight()
Sheets("Final Month").Select
Range("A2:B1055").Select
Selection.Copy
Sheets("Final Weight").Select

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

View 2 Replies View Related

Code To Stop Macro And Move On If No Value Found

Jul 2, 2013

I have created a few macros and once I was happy that they worked independently I joined them to run as one macro in several steps. I have just discovered a bug ...

The macro filters on a column and copies and pastes that range into another sheet.

HOwever, sometimes (as I have just discovered) when it filters, there will be no data against the value it is looking for.

I need to say, if no value, move to next step.

I.e. here's my code. It's looking for ASIA and it will copy and paste all rows with Asia to another page. It then does the same for EMEA. Thing is, in my example just now, there was no EMEA data and some times there may be no ASIA data so I need to build in some rules that if it does not find either of these it continues to finish macro or pops up and says 'NO ASIA found, CLick to continue' or something?

Selection.AutoFilter
ActiveSheet.Range("$A$12:AA" & lngLast).AutoFilter Field:=27, Criteria1:="ASIA"
Range("A13:Z" & lngLast).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("ASIA DETAIL ").Select
Range("A19").Select

[code]...

View 1 Replies View Related

VBA Macro To Find Text, Offset Column/Row & Copy

May 13, 2009

I am in the process of writing a VBA code(I should I am fairly new to this code writing!!!).What I need to be able to do is below.(enclosed please find a output in an xls file) What I should be able to do is below:

1.Find the text "Cash(No Listing)(Monthly)"

2. Offset to the 13th Column after that

3.Select the value in this column ,copy the value

4.Go to a row above and move one column to the left i.e.offset (-1,-1) and move 12 column backwards i.e.offset(0,-12)

5.Copy the value in 3 above to this entire range

6.Repeat this process for the entire file

My code is as below.Let me know where am I making a mistake. Just to let you know that this code performs the job well for the first entry i.e in the yellow makde area and doesn't do the job for any further entries .Llooks like I have some problem with the loop but not sure as to whats happening!

View 3 Replies View Related

Macro To Find Specific Text In Column And Copy Certain Cells In Same Row To Different Sheet

Dec 30, 2011

how to work macros or VBA

I have a workbook with multiple sheets named by month and year that I use to keep track of loans I work with at a bank. In these sheets I have info such as:

Column B = due date
Column D = loan# A
Column E = loan# B
Column F = status
Column H = followup needed
(Columns A,C, and G aren't important for the current need)

What I am trying to do is create a main sheet (TRACKER) that all I will have to do is press a macro button and it will pull info for each loan that is in a pending status.

I need a macro that will search column F (Status) on all sheets and find each instance of "Pending" and once that is done, copy rows B,D,E, and H in each "Pending" instance and copy them to their designated area on my TRACKER sheet. After that is done I need it to continue to the next "pending" instance and do the same on the next available line on my TRACKER sheet.

The overall goal would be that everyday I can press the macro and it will repopulate the sheet with the current pending items (as each day I will change pending status' to complete and no longer need to track it the next day).

I already have the tracker sheet set up and ready to go with the spaces as follows:
Column G&H = Merged cells where due date will need to go
Column I&J = Merged cells where loan# A will need to go
Column K&L = Merged cells where loan# B will need to go
Column M thru S = Merged cells where followup needed will need to go

View 9 Replies View Related

Macro Code: Find Cell Or Row Multiple Criteria

Sep 14, 2006

I can't seem to find the answer to this. In VBA, how do you Find a cell or row based on multiple criteria? All I need is to find it's location. If it helps, here's an example:

Sheet 1 contains source data:
Date Name Time Complete

Sheet 2 contains an interactive worksheet using this data. On Sheet 1 there's an entry: 9/12/2006 George 03:30 PM

Sheet 2 displays those records with adjacent cells for entering data. When data is entered, I need the system to go back to Sheet 1, find the entry that matches this one, and put an "x" in the Complete column.

View 6 Replies View Related

Return Column Number When Specific Text Is Found

Apr 29, 2014

I am looking for a formula to return the column number of the array when a specific text is found, in this case the text is "Yes"

The Array will only ever be 5 cells beside each other in a row

for example, M4:Q4, will be as follows - No No No Yes No

I want a formula to look at these 5 cells and return the number 4 as that is where the "Yes" value is

View 5 Replies View Related

Lookup Via Macro Code: Find The Match And Then Select That Cell In VBA

May 24, 2008

I have a large database of equipment on one sheet and an input form on another. For inventory control, when a user scans a number into the input form, the main inventory sheet is updated with the current location. I have it working using functions, but I need to do this in VBA. I am looking to do the following;

User enters 2222 on the input form. The code matches 2222 on the inventory sheet, moves the activecell 10 columns and updates a value in that cell. Cell A2343 is "2222" then Cell K2343 is changed to "WAREHOUSE 4". What is the best way to find the match and then select that cell in VBA?

View 8 Replies View Related

Lookup Names Within Text And Return That Name To Separate Column If Found

Jun 13, 2013

I'm using a formula to lookup names within text and return that name to a separate column if it's found.

The formula is =INDEX($E$1024:$E$1026,MATCH(FALSE,ISERROR(FIND($E$1024:$E$1026,E1010)),0))

I understand index and match functions, but I'm confused regarding the use of FALSE as the lookup value and the iserror(find( usage.

View 2 Replies View Related

Find Keywords Within Cell Text Of Another Column?

Nov 8, 2013

I'm evaluating the effectiveness of a keyword list we use to identify certain, high priorit,y medical situations from a string of text.

So, I have a column on a sheet of data (EIS Report!"B:B") in this case, and a seperate column on another sheet with keywords (Keywords!"A2:A47").

I use the formula ={OR(NOT(ISERROR(FIND(keywords!$A$2:$A$47,$B2))))} to identify if any of the keywords exist in the string.
This works well but I would like to improve my work in two ways:

1 - Identfiy, in another column on the EIS report sheet, which keyword it is that's been found within the string,
2 - On the keyword sheet, add another column of words, which if found within the string, would act as an exclusion.For example, I might use "STAB" as a keyword to look for "Male stabbed" etc, however might want to exclude "STABBING" to stop the solution triggering on "STABBING PAINS IN ABDO"

How might i adjust my formula?

View 9 Replies View Related

Set Variable To Found Cell Using Find Method

Jun 17, 2008

If Not stfound Is Nothing Then 'if value is found then do this

is causing me a run time error 424 when I try and run my code "Object required". Entire code is pasted below...

Option Explicit ....

View 4 Replies View Related

Macro To Insert Column If Not Found?

Sep 4, 2013

I would like a macro to order the columns as per the hardcoded list. If the column is not found than add the column at the position as per the hardcoded list. Below macro does the first part of re-ordering however if the column is not found how do I add an empty column:

Sub Reorder_Columns()
Dim ColOrder As Variant, i As Integer, Found As Range
ColOrder = Array("LogicalFileName", "LogicalFilePath", "UploadedDate", "UploadedBy",

[Code].....

View 1 Replies View Related

Running A Macro When A Certain Value Is Found Anywhere In A Certain Column

Nov 26, 2008

I’m working in Excel ’03 with a large table. I’m hoping to run a macro against a cell with value ‘X’ whenever that value is found within a particular column. I’d like this to be relative and not tied to a particular column so I can tweak it as needed down the road and run it against different columns.

In the example below, lets say I’m working with column B. I’d like something that would go through every cell in the column and run a macro when it comes across a particular value. Let’s say this value is x.

__A B C D E F
1 a x a a a x
2 b a b b b a
3 c x c c c c
4 f f f x f f
5 s s s a s s
6 g x g g g x
7 a a a a a a
8 s s s s s s

So, in my example, the macro would be run on B1, B3, and B6. And, if I wanted to go back in later, I could run this on column D and the macro would run on cell D4.

View 9 Replies View Related

Find Last Number In Row / Add 1 To Current Cell (if Another Cell In That Column Has Text)

May 23, 2014

file storage

1. Look at the "Days so far" section

2. Ignore cell C1

3. All the other cells in that row are shaded blue. Look at these.

4. Look at the "Volunteer" row - all the cells in that row are shaded blue. Look at these.

5. Wherever a name - any name - appears in the "Volunteer" row, 1 is added to the previous number in the "Days so far" section and the result is displayed in cell from the "Days so far" row above that Volunteer's name.

6. For example, we begin in C1 with a count of 12 days so far - this was manually entered

7. In cell H5, we see Henry has volunteered 1 day. The total no. of days so far should now be 12+1. Therefore, the number in H1 should be 13.

8. In cell G47, we see Joseph has volunteered 1 day. The total number of days volunteered BEFORE Joseph volunteered is 15 (see cell D43). But now, with Joseph volunteering 1 day, the total no. of days so far should now be 15+1. Therefore, the number in G43 should be 16.

9. what formula l must put in the "Days so far" row (excluding cell C1, which is manually input) to give me the "should be" results predicted in that row? I'm guessing it will be a formula which looks at each row fragment of the "Days so far" row, row by row, right up to the previous cell in that row, all within one formula.

P.S. I just want to leave the "Days so far" row blank, for any columns where there are no volunteers in the "Volunteer" row, so please don't give a formula which inserts zero for days with no volunteer, and then sums the cumulative total.

View 5 Replies View Related

Find Cell Value In Column & Return Text In Adjacent Cell

Jun 10, 2008

I have a drop down list in a merged cell B12-F12 and B13-F13 and B14-F14 . . . B30-F30.

I need the adjacent merged cell to populate a reason (text) based on the text answer in the drop down list or the entered text in the first merged cell. For example in the cell B12-F12 the user picks from the list or types in "Amiodarone." I want the adjacent merged cell G12-J12to automatically fill with "Heart Rhythm." I also want to be able to set up multiple if - them statements like if Amiodarone is entered then fill adjacent cell with Heart Rhythm and if Toprol XL then fill adjacent cell with Heart / Blood pressure and if simvastatin then fill adjacent cell with Cholesterol, etc. I have about 30 different options for cell 1 that I want to have auto fill in cell 2 based on the contents of cell 1. I've attached my file.

I want the user to be able to choose from the list or type the drug name in.

View 8 Replies View Related

Find Value, Copy Adjacent Cell & Paste To Corresponding Cell Of Another Found Value

Apr 5, 2008

I have found many posts similar to what I am trying to accomplish, but nothing that I have been able to modify and make work. I need a VBA script that will find a cell with the text data "Difference" and copy the adjacent (to the right) cell's data. I then need to find a cell with text data "Ops" and paste the previous data to it's adjacent cell.

View 3 Replies View Related

Searching A Column For Specific Text To Return A Number Of Items Found

Apr 28, 2006

on one sheet we have a summary of the main list, which includes totals of money recieved, totals of all the different sources (ie, where they heard about us from), the totals of the frequencies they pay (ie, how many donate monthly, quarterly...) ... etc. on the next sheet we have the "main" list of donors, their IDs, amounts, frequency, source ...

the totals on the first sheet are updated manually, but i want to change that as there are a great number of errors.

View 8 Replies View Related







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