Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How To Iterate a range of cells?

Thanks, I'll try that

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SOLVER does not iterate / work BHatMJ Excel Discussion (Misc queries) 4 August 12th 09 10:42 PM
Iterate Circular Reference Brandt Excel Discussion (Misc queries) 1 August 3rd 05 11:43 PM
Iterate through the values in a named range? Brian Excel Programming 1 June 2nd 04 05:04 AM
VBA: How to iterate through each cell of one specific row Hank[_3_] Excel Programming 3 February 26th 04 11:14 PM
Iterate columns wired Excel Programming 9 November 14th 03 11:14 PM


All times are GMT +1. The time now is 04:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"