Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-15-2011, 08:12 AM
doorsgirl doorsgirl is offline Concatenated data in subsequent rows Windows XP Concatenated data in subsequent rows Office 2010 32bit
Novice
Concatenated data in subsequent rows
 
Join Date: Sep 2011
Posts: 3
doorsgirl is on a distinguished road
Default Concatenated data in subsequent rows

We would like to list concatenated city names and services. I am trying to have it so we can use a VLOOKUP-type function where if we type in a city name, that city's concatenated data appears in another row. Here's the kicker - we would like to be able to type in other city name in that same original cell and have that new city's concatenated data appear under the first city's data. It would look something like this:

SERVICE1CITYNAME1
SERVICE2CITYNAME1
SERVICE3CITYNAME1
SERVICE4CITYNAME1
SERVICE1CITYNAME2
SERVICE2CITYNAME2
SERVICE3CITYNAME2
SERVICE4CITYNAME2
SERVICE1CITYNAME3
SERVICE2CITYNAME3
SERVICE3CITYNAME3
SERVICE4CITYNAME3



Etc.

Any help would be greatly appreciated, as I am under the gun here!
Attached Files
File Type: xlsx PROJECT2.xlsx (11.9 KB, 11 views)
Reply With Quote
  #2  
Old 09-15-2011, 09:21 AM
Catalin.B Catalin.B is offline Concatenated data in subsequent rows Windows Vista Concatenated data in subsequent rows Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

try this macro: (same in file attached):
Sub concatenate()
Dim nextRow As Long
With Sheets("Sheet1")
nextRow = Range("G" & Rows.Count).End(xlUp).Row + 1
Cells(nextRow, "G").Value = Cells(2, "A").Value & Cells(5, "D").Value
Cells(nextRow + 1, "G").Value = Cells(3, "A").Value & Cells(5, "D").Value
Cells(nextRow + 2, "G").Value = Cells(4, "A").Value & Cells(5, "D").Value
Cells(nextRow + 3, "G").Value = Cells(5, "A").Value & Cells(5, "D").Value
MsgBox "Mission accomplished! "
End With
End Sub
Attached Files
File Type: xlsm Copie a PROJECT2.xlsm (18.4 KB, 10 views)
Reply With Quote
  #3  
Old 09-15-2011, 09:56 AM
doorsgirl doorsgirl is offline Concatenated data in subsequent rows Windows XP Concatenated data in subsequent rows Office 2010 32bit
Novice
Concatenated data in subsequent rows
 
Join Date: Sep 2011
Posts: 3
doorsgirl is on a distinguished road
Default

Catalin.B - thank you! If I manually enter a city name in the yellow box rather than select from the drop down, I do get an error message. However, it's just an extra click to go through to get the desired effect. Thanks again! That did the trick!
Reply With Quote
  #4  
Old 09-15-2011, 10:58 AM
doorsgirl doorsgirl is offline Concatenated data in subsequent rows Windows XP Concatenated data in subsequent rows Office 2010 32bit
Novice
Concatenated data in subsequent rows
 
Join Date: Sep 2011
Posts: 3
doorsgirl is on a distinguished road
Red face Spoke too soon...

My boss just notified me of the following:

I need up to 5 input lines for the cities, not just one. I don’t want to have to type the City name and press “Start” after each city name, though the way it appends in a list at the bottom is good – the outcome is right, the process almost there. I want to put in ALL city names, then press start ONCE, and then have it produce the entire result.


Any suggestions on how I could do that?
Reply With Quote
  #5  
Old 09-15-2011, 10:37 PM
Catalin.B Catalin.B is offline Concatenated data in subsequent rows Windows Vista Concatenated data in subsequent rows Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

cell D5 was formatted with data validation to allow only Cities from column B to appear in drop down list... and it was set to give you a message if you enter a city that is not in column B list...
Code:
Sub concatenate()
Dim nextRow As Long, i As Integer
With Sheets("Sheet1")
For i = 5 To 9
nextRow = Range("G" & Rows.Count).End(xlUp).Row + 1
Cells(nextRow, "G").Value = Cells(2, "A").Value & Cells(i, "D").Value
Cells(nextRow + 1, "G").Value = Cells(3, "A").Value & Cells(i, "D").Value
Cells(nextRow + 2, "G").Value = Cells(4, "A").Value & Cells(i, "D").Value
Cells(nextRow + 3, "G").Value = Cells(5, "A").Value & Cells(i, "D").Value
Next i
MsgBox "Mission accomplished! :)"
End With
End Sub
Here is the new code for what you need. Now it is set to take values from range D5 to D9, but you can set your desired number of cities by changing in this line:
Code:
For i = 5 To 9
to
Code:
For i = 5 To 100
... And if you do not want the message box to appear, just delete code line 11
Attached Files
File Type: xlsm Copie a PROJECT2.xlsm (18.1 KB, 9 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenated data in subsequent rows Odd behaviour of table - keep rows together Stephan Lindner Word Tables 1 09-10-2011 05:31 AM
Product and Sum on 2 rows apolloman Excel 2 04-27-2011 07:14 AM
Concatenated data in subsequent rows Rows to Columns kyakobi Excel 5 12-07-2010 03:12 PM
Concatenated data in subsequent rows Average of many rows speedycorn1 Excel 1 10-30-2010 07:54 PM
Concatenated data in subsequent rows How do I turn the top 2 rows into a header GR8Fandini Excel 1 02-06-2010 12:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft