Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
I need to make a macro that does the following things:
1. Search for a specific string in one column; 2. If the string is found, add the value in same row, but in differen column to a variable; 3. Display that variable in a specific cell; The points I can't seem to be managing to do are 1. and maybe 2. Is there anyone who could help me? Thanks in advance, Nun -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
lrow = Sheet1.UsedRange.Row + Sheet1.UsedRange.Rows.Count
col = column number you are searching n = Destination cell Row p = Destination Cell Column For x = 1 To lrow If Cells(x, col).Value = "Search String" Then varNum = Cells(x, col).Value + Cells(x, col + 1).Value Cells(n, p).Value = varNum End If Next -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
just use the VLOOKUP function as follows
VariableToAdd Application.WorksheetFunction.VLookup(str,range("A 1:B10"),2) where str is your string and column A1 to A10 contains all the string and cloumn B1 to B10 contain the numbers. - Manges -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
|
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
Careful though. I blieve that will only work if you know for a fact yo
will only get one match for your lookup string -- Message posted from http://www.ExcelForum.com |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How To Iterate a range of cells?
Yeah...I've just noticed that. The VLookUp aproach is nice, but onl
accounts for ONE occurence of the string... This is to automate production of Totals, from Sub-Total Cells. The Sub-Totals are made by =Sum(). Now, I need to automate th production of Totals, which will be the sum of all Sub-Totals, which never lknow how many they are, reason for which I need to iterate th cells looking for the string "Sub-Total". Was I clear? If not please tell me. Sometimes I do have the tendency t maku simple things, complicated ones. :s StargazerN -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SOLVER does not iterate / work | Excel Discussion (Misc queries) | |||
Iterate Circular Reference | Excel Discussion (Misc queries) | |||
Iterate through the values in a named range? | Excel Programming | |||
VBA: How to iterate through each cell of one specific row | Excel Programming | |||
Iterate columns | Excel Programming |