0

I need to insert two sets of data, separated by a comma, into the same cell using a macro. The data is located in a separate sheet of the workbook. I need to pull it into a summary sheet I have created.

The two values that should be concatenated are based on an ID from the summary screen. I'm not sure how to do this in VBA.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
  • Welcome to StackOverflow. Please take a moment to read the guidelines in the Help Center on asking questions on this site. As it stands, your question is "too broad": it doesn't provide enough information to enable a targeted and concise Answer. At the very least, you need to provide the code you've tried and explain HOW it doesn't work. – Cindy Meister Feb 15 '16 at 20:40
  • Sounds like you need to concatentate. Check out this post: http://stackoverflow.com/questions/1727699/how-to-concatenate-strings-in-vba – Wyatt Shipman Feb 15 '16 at 21:30
  • I'm not sure of any of the sheet names, column names, cells, or anything else but you can adapt this for use: Range("C1").FormulaR1C1 = Range("A1") & ", " & Range("B1") – justkrys Feb 15 '16 at 22:09

1 Answers1

0

You are looking for CONCATENATE.

=CONCATENATE(Sheet1!B2,",",Sheet2!A2)

In this example, B2 and A2 are whatever arbitrary cells your data is in. You can replace Sheet1!B2, for instance, with another formula (such as VLOOKUP) to take into account your index.

To just test out the CONCATENATE function, you can do this:

=CONCATENATE("Foo",",","Bar")

Which will evaluate to Foo,Bar inside that cell. Replace "Foo" and "Bar" with other formulas to get a more complex result.

(If you provide more information about the structure of your sheets and how the index relates to the data you're looking up, we can provide a more detailed explanation.)

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102