Loop Through Range Find Values?
Dec 6, 2013
I'm working with reports where I am given a list of used RFID tags which contain 13 alpha-numeric characters, and need to compare it against another list, in order to determine if any are matching. I'd like to be able to loop through one column of values to compare against the other, but unfortunately my VBA skills aren't that great..
View 5 Replies
ADVERTISEMENT
Jun 3, 2009
Hi, I'm very new to writing Excel Macro's and wanted to know if I could do the following. Conceptually, I understand what I need done and think it should be fairly straightforward.
There's 2 main events in this loop (I hope that's the correct terminology):
Input 1) User defines the beginning cell to start the loop. In this case, A2.
Input 2) User defines the range of columns/rows to display. The formula for rows that I've thought of is 4r. So if a user wants 20 rows below cells A2, they simply input 5 for r. The number of columns is a constant 5. So if r=5, then I'd want the range to be A2:E22......
View 13 Replies
View Related
Feb 23, 2010
I have a very large worksheet (row count maxed in 2007, and then some), for which I need to do the following: search column A for a string that will occur many times, and then check the 10 cells that follow in its row for negative values, dropping some sort of indicator in the 11th (shading it red or something would be fine). An additional bonus would be if the 10 cells that possibly contain a negative could be summed (the sum could serve as the indicator?). If no negative is found, nothing need be done, and the macro should chug along searching A for the next reference to this string.
My hope was to do a sort of "With Range("A:A"), .Find("MyString")", save position as StartPos, do the 10-cell row checking in a nested IF or For (though the For would take a long while, checking each cell individually), then doing a .FindNext after StartPos until = StartPos (does .FindNext loop back to the top?). The formatting of the indicator cell in the 12th cell in each relevant row doesn't really matter, it's more just for jumping to critical rows.
View 3 Replies
View Related
Jun 20, 2012
I have a range (C3:C56). I have a set number in each of these cells. I also have a range out to the side that calculates a number after input a % in cell BI2. The formula reads as "=AE3-(AE3*$BI$2)". Basically it is reducing the values in my range. If a number is in my range is 8 and i input 25% in cell BI2, then my result would be 6.
I have a few steps I want to happen with this range.
1 Display an input box asking for a percentage
2 I want to loop through my range and use that percentage to reduce the numbers
3 (optional but would be amazing to have) after the reduced value is determined, round down to the nearest multiple of 4.
View 9 Replies
View Related
Mar 21, 2014
I built a Microsoft Access database for my church to track member information. I was able to import a lot of the needed information to create the records for each individual and household easily. What I can't do is import their offering donations until it is "Normalized." Which means that I need each row to be 1 record with the fields listed as the column headings. My church has a spreadsheet with several sheets one of which is named Input. I've attached the desensitized file for you to view/play with.
What I need to do is loop through the input sheet and find all the values in range B:4 to GN:387 that are greater than zero or not null (I believe they entered the default as zero so their other calculations would work). Then I need those values to be transferred to the column labeled Offering Amount on the ImporttoAccess sheet. Somehow I also need to define three variables associated with the cell that is contains a value greater than zero.
1. I need the row heading value for the envelope number (Column A of input sheet) which intersects with the amount
2. I need the column heading value (3 field merged) for the date (Row 1 of input sheet) which intersects with the amount
3. I need the column heading value (labeled: GenFund, WLA, or Missions) for the designation of the offering (Row 2 of input sheet) which intersects with the amount
Each of these I need to attach to the value offering amount and insert into their corresponding column fields for that record. I have entered 2 example rows of data into the ImporttoAccess sheet for you to see what I am after. I am sure it's possible since the data is there, But how to go about it.
View 4 Replies
View Related
Aug 30, 2006
I have 2 worksheets. The first sheet has data of which some needs to be copied to a second worksheet. The trigger is a value found in column E. If a match is found, then a copy statement needs to be built. The values in F, G & H are the values to be used in the copy statement. The content of cell H may be numbers or letters or both.
What is the correct format of the copy statement?
Dimension all variables
Dim RowPointer As Long
Dim wbContrib As Workbook
Dim wbMaster As Workbook
Dim SheetName As String
Dim target_sheet As String
Dim target_cell As String
Dim Target_value As String
Dim CellAddr
'
' Initialize variables
Set RowPointer = 1
Set wbMaster = “Master.xls”
'
'******************************
View 9 Replies
View Related
Feb 23, 2010
In my workbook I have about 20 sheets (less in the attached sample), and on most sheets I’d like to query data for each day and find an average value based on the time and then copy that result into another sheet. I’m not sure if I’ll need 2 macro’s for this or if one can be used.
Here’s a quick description:
Assuming that I am currently in the sheet I want to run the macro, then I will either input “1:45” or “0:45” into a popup box, or I could always simply input the 1:45 or 0:45 in the code itself. I’m flexible
1:45:
If I input 1:45, then I’d like the macro to find the first 1:45 in Column B and the value in the same row in Column F will be used in the calculation. Once 1:45 is located, then the macro moves up to find 22:45 in Column B and the value in the same row in Column F will be used in the calculation.....
View 11 Replies
View Related
Jan 11, 2007
I have a piece of code which, amongst other things, searches column A of one sheet for certain values and then pastes relevant data to a different sheet.
A lot of the data is fixed in relation to the entry in column A e.g. the 'Open Date' is always 8 rows down and 1 row across from the value I search for. These pieces of data easy to transfer to the other sheet.
However, one piece of data could be anywhere within a 10 row, 4 column region offset from the value in column A i.e. if column A is on row 12, then the data I am looking for could be anywhere in the range B20:E30.
View 5 Replies
View Related
Mar 31, 2008
With Sheets("regrade pharm_standalone")
For Each r In .Range("standaloneTerritory")
If r.Value = "X101" Then
r.EntireRow.Copy
Sheets("X101").Range("A1").End(xlDown).Offset(1).PasteSpecial xlPasteValues
End If
Next r
End With
-------------------
I need to repeat this loop for values from X101 to X151. In all cases, the sheet name is equal to the value I'm looking up (eg: value = X102 goes to sheet X102).
I have a named range called 'territories' that contains the list of X101 -> X152.
I'm hoping to make the code perform the loop for each of the territories without my having to copy & paste and change the 'X101' 51 times as this would seem a rather silly thing to do!
View 9 Replies
View Related
Aug 13, 2008
I now have everything set up to do exactly what I want except this last bit.
All I want is for the overview page to show the top three referrers for each month. At the moment, it's finding the top and bottom 'scorer' but if more than one has the same score I can only see the first alphabetically.
View 10 Replies
View Related
Mar 24, 2013
I'm looking for a formula that would tell me if a value in colume E can be found in column M while the values in column M may have characters before and after the value I'm looking for. The values are alpha and numberic in many cases.
Find E2 in M:M where E2 = 0123 and is in M:M as a15012388. The "yes/no" result is marked in red where I would like to have the answer.
Description
Looking For
Yes/No
[Code].....
View 4 Replies
View Related
Jun 12, 2014
I have a workbook with three sheets containing patient information from a clinic. Each sheet pertains to a different year. The sheets are formatted such that every row of each sheet contains a patient ID number in column A; in the same row, following the patient ID, is data pertaining to that patient, part of which stays the same (intake data)[=values in columns B:O] and part of which changes (encounter data)[=columns P:AA].
My challenge in cleaning and merging this dataset is that the ID numbers may not be trustworthy: I need a way to validate that there are no patient records [=rows] such that a given row has the same set of identifying information (OpenRecord Date, Sex, Age, History, etc.) located in columns B through O but a different ID number (column A) in a different sheet. In other words, I need to make sure the same patient isn't masquerading by a different ID number across different years [=worksheets]. What I am trying to do is develop a macro or formula that compares each row's range of values for B:O to every other row across each of the three worksheets; then find and list only matches for B:O that do not have the same value in Col A.
Complicating this operation are two considerations: 1) Each sheet in the workbook (excerpt attached) contains about 40,000 rows. 2) DOB is missing; instead, we have "Age." For those patients which appear in all three years captured in the three sheets, the "Age" value (column F) increases by +1 year.
A link to an example file on Google Drive : [URL] ....
View 2 Replies
View Related
May 8, 2008
I would like to be able to replace all cell values in a range of 20c by 20r (i.e. 400 cells). In all cases the condition would be the same (find all cells with a value greater than than zero), but then replace with different values.
e.g. Cells with value >0 in range CX119:DQ138 replace with "NT", then cells with value of >0 in range DR119:EK138 replace with "NU"
I thought you could do it with find and replace by just selecting that range of cells but can't see how to set the conditional >0 bit.
View 9 Replies
View Related
Feb 20, 2007
I'm trying to use this Find Method and combine it with a countif or loop. Something that will count a number of occurences of a unique type of character. I'm looking to find all "F" characters in Bold, Italic and Size 16. Here's my find code that I'm trying to use. I can get it to work by itself but not along with a countif or loop.
Sub count_4()
Dim r As Range
Set r = Range("A1:A6")
With Application.FindFormat.Font
.Bold = True
.Italic = True
.Size = 16
End With
r.Find(What:="F", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, searchformat:=True, MatchCase:=True).Activate
End Sub
View 4 Replies
View Related
Mar 29, 2014
I know the formula =large but my problem is the formula for the equivalent value for it. Note: In my xcel file attached you can see there are multiple items with the same total numbers and also blanks
View 3 Replies
View Related
Aug 1, 2008
I'm trying to create a spreadsheet to update daily, whenever our market intelligence arrives by email. I'm not trying to write a macro which can select a range of cells (G:L) relative to the date in Column B, which represents the value in cell P6. In other words:Read the value of cell P6 Find that value in column B (e.g. B646)highlight the cells in columns G through to L on that row (e.g. select G646:L646) I am then aiming to paste the values in that range of cells, so that those stay in the spreadsheet and are not lost when the next lot of figures comes in the following day.
Range("G646:L646").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=12
Application.CutCopyMode = False
ActiveWorkbook.Save
but that's obviously a static range, rather than looking up the date first.
View 2 Replies
View Related
Jul 13, 2014
I have Excel 2013. I would like to use the code below but I need it to let me select the range instead of specifying it in the code, then pop up a form into which I can fill in what I want it to search and what I need it replaced with.
[Code] ......
View 3 Replies
View Related
Feb 28, 2012
I have four named ranges (Segment, Keyword, Impressions and Dropdown) and I would like to create a formula-based ranking of keywords by impressions and clicks. Using the following array formula, I am able to return the correct values for impressions or clicks:
{=LARGE(IF(Segment=DropDown,Impressions),$H7)} where $H7 is the number ranking 1, 2, 3 etc.
My question is what array formula could be used to find which row in the array returned that number and then pulls the data from the same row in the other named ranges?
Essentially find row of {=LARGE(IF(Segment=DropDown,Impressions),$H7)} but return Keyword and Clicks on that row.
Other Notes: I cannot use pivot tables and some values might be the same which would make Vlookups not accurate for duplicate values.
Link to an example document to clarify this. [URL] .......
View 9 Replies
View Related
Jan 3, 2013
In my workbook I have two tabs, the first tab is intended to call on data located on the second tab so I can evaluate & Display it in different ways. Here's what's worked so far. Where I'm stuck is attempts to try and combine the two.
- the second tab is named AW_Items_Import
Examples:
1) Looking on the second tab to count the number of times a object (identified on the first tab in Cell B13) appears
=COUNTIF(AW_Items_Import!J:J,B13)
2) Looking on the second tab for items that fall within a set value range, the ranges specified on the first tab in cells C14 and E14
=COUNTIF(AW_Items_Import!G:G,">=" & C14) - COUNTIF(AW_Items_Import!G:G,">" & E14)
What I want to do, is combine 1) and 2) so I can isolate a search to a name specified on the first tab, THEN count the number of times that item falls within a set range, the range also specified on the first tab.
View 9 Replies
View Related
May 23, 2009
I've attached a workbook which contains two sheets:
PAYM
DEVICE_PAYM
Data is updated on DEVICE_PAYM each day with the figures I need located in column "AN". I need to be able to copy the data from "AN" and paste it into a column on the PAYM sheet. The destination column on the PAYM sheet needs to be specified by inputting a specific date - ideally, I would like to use the calendar Add-In as part of this process. I've already input some code for the calendar but am unable to develop this further so that it finds the correct date column and pastes the data across from the other sheet.
View 2 Replies
View Related
Feb 1, 2010
I'm working on a project for my company. We make plastic tanks and for quality control we want to start recording the thickness of the tanks in different areas/zones of each tank.
Attached to this message is an Excel sheet that I've been working on. From "Sheet 1", it records inputted thicknesses into WorkSheet "1098". On the top of "1098", it shows all of the recordings, and just below that are the "10 Most Recent Entries".
Right below the "10 Most Recent Entries", there are formulas to calculate the Min and Max Values. Whenever a new entry is recorded, the selected cells for the Min and Max formulas change. Is there a way to force the cells to always stay the same?
View 3 Replies
View Related
Jun 5, 2014
i have a data sheet and i am trying to store the row value of a user input time. for the most part my code works but for certain times it returns a 0. it seems like times which end with a 3 are not returning any value.
my code looks kind of like this:
Dim StartA As Date
StartA = InputBox("First start time (ex: 2:30pm)")
For i = 1 To 9000
[Code]....
View 6 Replies
View Related
Nov 21, 2006
i have a piece of code which i have cobbles together from many different sources, to many to list, but i know I have had some help from some of the people in this forum.
first of, i know some of the code might be a bit shaky, but please bear in mind that i am very, very new to VBA.
basically the code is reading the first usable line of the "Mapping" sheet to get information, then it searches for that information in the "GLEX" sheet. If it finds the information that was searched for in the "GLEX" sheet, it will copy it to the "Calc" sheet. the "Calc" sheet contains a formula that does a sum on everything in the P column. It then takes the value in the P column on the Calc sheet and pasts it into a cell that it reads from the "Mapping" sheet.
If i run the code, it seems to be doing what I want it to do for the first line in the mapping sheet, but how do i make it continue?
If must read the value of the first usable line in the "Mapping" sheet, then search for those values in the GLEX sheet, if it find a match it must copy the whole line to a next sheet and then CONTINUE SEARCHING. the mapping sheet. Once it has search the whole GLEX sheet and copied all the matches to the calc sheet, it must perform the rest of the functions. after everything has been completed for the first line in the Mapping sheet, it must do the same for the second line.
That means that there must be a loop in a loop.
I have also included some sample data.
Sub Accrule()
Sheets("Mapping").Select
Dim Org_Area As Variant
Org_Area = Worksheets("Mapping").Range("A3").Value
Dim Item As Variant
Item = Worksheets("Mapping").Range("B3").Value
View 9 Replies
View Related
Nov 22, 2011
I have a process where I need to search for multiple customer numbers and delete line associated with them.
My question is how do I create this process to run in a loop going through all 10 numbers?
View 1 Replies
View Related
Dec 19, 2006
I am using Range. Find() and Range.FindNext() Method. As per my knowledge FindNext() advances in the text and searches for same string found using Find(). I have used Find() for two different searches in Sheet. (Eg. Find() text "Risk" and Find text "ACL", Now when I use FindNext() for the second time (to search "ACL" text), next time when I use FindNext() to search first text ("Risk" it searches prev text - "ACL"). I have used them in a loop. Below is the code i have used.
Set SrcCell = SourceBook.Worksheets(1).Columns("A").Find("Risk", After:=Sheets("SubArea").Range("A21"), LookIn:=xlValues, lookat:=xlWhole)
'Set srcCell = SourceBook.Worksheets(1).Columns("A").FindNext
Set firstSrcCell = SrcCell
Do While Not (SrcCell Is Nothing)
tgtCell.Offset(tgtRow, 0) = SrcCell.Offset(-1, 255)
tgtCell.Offset(tgtRow, 1) = subAreaId
tgtCell.Offset(tgtRow, 2) = SrcCell.Offset(0, 1)
tgtCell.Offset(tgtRow, 3) = SrcCell.Offset(1, 1)
tgtCell.Offset(tgtRow, 5) = SrcCell.Offset(3, 1)
tgtCell.Offset(tgtRow, 6) = SrcCell.Offset(2, 1)
RiskId = SrcCell.Offset(-1, 255)
'tgtCell.Offset(tgtRow, 0) = SrcCell.Offset(0, 255)...............
View 2 Replies
View Related
Jan 25, 2007
I have a sheet with data on it. In column 5 I have adate range and I would like to delete and values which have "01/01/1900". Currently I have created a loop but for some reason it does nothing. I can use the find option and it picks up the cells with the ones on. For some reason it seems that it cant find them cells.
The code is as follows
Sub jdate()
rowcn = 8
target_sheet = "Status Report"
Do
'status_flag = 0
If Sheets(target_sheet).Cells(rowcn, 5) = "01/01/1900" Then
Sheets(target_sheet).Cells(rowcn, 5) = ""
End If
rowcn = rowcn + 1
Loop While Sheets(target_sheet).Cells(rowcn, 1) > 0
End Sub
View 9 Replies
View Related
Feb 2, 2010
I have a base document that i can import another data document with a button (this is working).
I then have another WS ("search") in the base document with lots of identifiers which I want to use as my search range to look through the document that I just imported (column A).
I need a msg to ask the user what month they would like to find the $ value on (Ie, January) in the imported WS... this way it doesnt copy the entire line only cell in the selected month column.
Then I want to the user to be able to click a button that will check through the identifiers on the "search" WS and if the same identifier appears in the imported WS in column A, then for the $ value in the column selected to be copied to the search Range work sheet.
If the idenfifier is not matched then in place of the $ value copied can be the string "no in XXX WS" .
I have attached the document with dummy data in each work sheet with details more cleary what I have meantion above.
View 9 Replies
View Related
Feb 17, 2010
I thought my code was working properly, but then I tried different numbers for myNum and I realize it's not. Here's the
View 5 Replies
View Related
Aug 21, 2009
I have an Excel workbook that i need to loop through all rows searching for a certain string we can call "Totals". There are more than one, and i need to grab the values from each at an offset in the same row, different column, to total at the bottom. I have tried a few things unsuccessfully. The code below is just my first step to try to find the row, i know there are problems as i am unfamiliar with the different properties of a given variable.
Function FindRow(szName) As Integer
nFoundRow = 0
For nRow = 0 To Worksheets("Totals").Columns(nCol).Rows.Count
If StrComp(Worksheets("Totals").Cells(1, nRow), szName) = 0 Then
nFoundRow = nRow
End If
Next nRow
FindRow = nFoundRow
End Function
Sub Totals()
nCol = FindRow("Totals")
ActiveCell.Select = nCol
MsgBox (nCol.Value)
End Sub
View 9 Replies
View Related
Feb 5, 2009
I've an excelsheet with quite advanced formulas that area really nested and using quite a bit of iteration.
What I would like to do is finding the maximum of
A while Amin<A<Amax
By changing B
There is a Variable C than should be constant unless it becomes larger than Cmax ( Cmax dependas on A,B ,C, D and all kinds of things)
If C is > than Cmax there is a variable D that can be changed has to be less or equal to Dmax
So the question is how to find the maximum of A while fulfilling all these variables?
What I've come up with so far is:
View 9 Replies
View Related