We help IT Professionals succeed at work.

Combine cell data based on adjacent cells?

95 Views
Last Modified: 2018-11-14
Combine cell data based on values in adjacent cells. Sample screenshot attached.

Is there a formula or VBA that can achieve this?
It's OK to have helper columns if needed.
screenshot
Comment
Watch Question

Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
If you can, please attach a sample workbook.

Author

Commented:
Spreadsheet attached....thanks
sample.xlsm

Author

Commented:
Would it be easier if there are blank rows separating cells?

I've been trying (without success) to find a VBA code that would do following:
If AB is NOT blank, concatenate values from AD until blank row reached

Author

Commented:
Will revise and re-post....added blank rows (hopefully it will be easier for VBA code)
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
It's not necessary. I'll have your solution in a few minutes.

Author

Commented:
Sound like solution is coming soon :)

Author

Commented:
Hi Martin,
See attached sample, if it's easier to achieve this with blank rows, that would work too....which ever version of the file works for you.
Thanks!
Book1.xlsx
Social distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Hi Martin,
Thanks for this...It's huge help!
Only thing I noticed that needs a tweak is the last row with info...it adds a bunch of semi-colons    ;;;;;;;;;;
Any way to correct that?

Author

Commented:
Never mind...I found a work-around. I'll have it delete rows after last one with info prior to running your code.
Just tested it...works great!

Thanks again!
Sasha
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Sorry I didn't notice that. There was some formatting below row 91 that caused VBA to miscalculate the last row with data. That's been corrected in the attached workbook.
29126114a.xlsm

Author

Commented:
Thanks again...I was really stuck on this :)
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
              Experts Exchange Top Expert VBA (current)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions