473,543 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel - concatenate a range

8,435 Recognized Expert Expert
Is there a simple way in Excel 2003 to concatenate a range of cells, rather than individual cells?

In other words, I want to enter =CONCATENATE(D2 :AN2) in a cell, but this produces an error. How can I work around it?
Mar 12 '08 #1
4 26681
Stang02GT
1,208 Recognized Expert Top Contributor
Hey Killer,

I did a quick google search on what you were looking for and found some good articles that explain how to do it... here they are..


Excel Tips

MS Excel

Hope that helps you !
Mar 12 '08 #2
Killer42
8,435 Recognized Expert Expert
Thanks for that. Think I'll go with the user-defined CONCAT function.
Mar 13 '08 #3
Stang02GT
1,208 Recognized Expert Top Contributor
Sure thing. I don't know if those links helped you?! But I figured I would at least try and find something to help ya out.
Mar 13 '08 #4
Killer42
8,435 Recognized Expert Expert
Hahahaha... it's got a bug in it. :D

The user-defined function in that "Excel Tips" returns #VALUE! if you include the optional delimiter, and the cells in the passed range are empty. This is because when doing the concatentation it adds an extra delimiter on the end. There's an extra piece of code to then remove it. But if nothing was concatenated, it tries to remove the last 'n' characters of an empty string, and doesn't work.

Here's a corrected version...
Expand|Select|Wrap|Line Numbers
  1. Function Concat(myRange As Range, Optional myDelimiter As String) As String
  2.   Dim r As Range
  3.   Application.Volatile
  4.   For Each r In myRange
  5.     If Len(r.Text) Then
  6.       Concat = Concat & IIf(Concat <> "", myDelimiter, "") & r.Text
  7.     End If
  8.   Next
  9. End Function
  10.  
By the way, is this like Word where I can move macros to the Normal template so they're always available? Couldn't work it out from the doco.
Mar 13 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

13
35495
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy...
0
2064
by: B | last post by:
Using Access2000, the sample code below is what I have been modifying and working on since the past week and I could not get it to work properly. What I wanted to accomplish: 1) read from a recordset and export to Excel 2) Excel is populated based from an ID (may possible be one or multiple) and renames the worksheet based from the ID 3)...
10
26573
by: Maik | last post by:
Hello, I've got a problem with access to special ranges. I renamed some cells (for example "C4" in "CUSTOM.GENERAL.VPRIM"). This is necessary, because I have to read out only these cells in active worksheet. The method get_range("RangeName", Missing.Value) is ok as far as I have an existing RangeName. My program compares the root of a...
2
1648
by: Ryan Riddell | last post by:
I wrote an application to pull data from certain ranges of an Excel workbook. The application works great for the first 2 of 4 sections I created. I created the third section of code and the code is correct; however, it isn't pulling the data. Below is a short / complete version of the page. I verified the problem is not in the code. I...
12
2336
by: Ed | last post by:
Hi All, I'm looking for an efficient way of dumping a table in a Dataset into an Excel sheet. I'm currently copying data cell by cell and this is rather inefficient for large Datasets. My current code is as follows: objExcel = New Excel.Application() objWorkBooks = objExcel.Workbooks
3
7299
by: afirst | last post by:
Hello. I have just started using macros in Excel- I recorded a simple formula-now I need the macro to work on a number of spreadsheets, regardless of the number of cases the spreadsheet contains Here's pieces of the macro Dim varNbRows As Double 'Determine how many records are in the file varNbRows =...
2
2323
by: bbasberg | last post by:
I have been working hard to clean up my code but I am still wondering why all incoming records go to the "AddNew" part of the IF statement and never to the Edit alternative. I believe that it must be because my rs.index never really receives the value from the cell in the spreadsheet that it should use to compare to the corresponding field in the...
1
2215
by: ATSRND | last post by:
I would like to write the code to select a range of worksheets in MS Excel 07, starting with the Activesheet and ending with the last sheet.
0
1735
by: attraankit | last post by:
i am working in asp. my concern is how to read an excel spreadsheet using asp, especially when the range in the excel spreadsheet is unknown. i am designing a user form where the use has to browse the excel spreadsheet and later application reads it and uploads its data into access databse. for this its obvious that i cant hard code the range...
0
7401
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7681
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3387
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
958
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
628
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.