Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
gh gh is offline
external usenet poster
 
Posts: 8
Default Iterate rows of spreadsheet(s}\Get values

I have two spreadsheets. The first one has a column with numbers in it.
The second one has a column with the same numbers and a description
column as well. Each number can have more than one description. What I
want to do do is iterate the rows in Sheet 1 and lookup the numbers in
sheet 2. Then return all the descriptions to sheet 1 and put them in
the cell next to the number. If there are multiple descriptions for a
number we would like them separated by a comma. Is there a function for
something like this?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Iterate rows of spreadsheet(s}\Get values

You can use the macro below.

Sub test()

With Sheets("Sheet1")
Sh1RowCount = 1
Do While .Range("A" & Sh1RowCount) < ""
data = .Range("A" & Sh1RowCount)
With Sheets("Sheet2")
Sh2RowCount = 1
Description = ""
Do While .Range("A" & Sh2RowCount) < ""
If .Range("A" & Sh2RowCount) = data Then
If Description = "" Then
Description = .Range("A" & Sh2RowCount)
Else
Description = Description & ", " & .Range("A" & Sh2RowCount)
End If
End If
Sh2RowCount = Sh2RowCount + 1
Loop
End With
.Range("B" & Sh1RowCount) = Description
Sh1RowCount = Sh1RowCount + 1
Loop
End With
End Sub


"gh" wrote:

I have two spreadsheets. The first one has a column with numbers in it.
The second one has a column with the same numbers and a description
column as well. Each number can have more than one description. What I
want to do do is iterate the rows in Sheet 1 and lookup the numbers in
sheet 2. Then return all the descriptions to sheet 1 and put them in
the cell next to the number. If there are multiple descriptions for a
number we would like them separated by a comma. Is there a function for
something like this?

TIA

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
Iterate rows, add like values - an easier way? Ed from AZ Excel Programming 1 April 3rd 08 06:09 PM
Extracting rows from a spreadsheet using values from another shee Alex 46 Excel Discussion (Misc queries) 1 January 31st 07 07:27 PM
Can't iterate thru a row with For peter Excel Programming 2 January 7th 05 04:46 AM
Iterate through the values in a named range? Brian Excel Programming 1 June 2nd 04 05:04 AM
Iterate columns wired Excel Programming 9 November 14th 03 11:14 PM


All times are GMT +1. The time now is 11:47 PM.

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

About Us

"It's about Microsoft Excel"