Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to combine the bold data from two or more cells into a single cell

Status
Not open for further replies.

jlks90

Technical User
Jul 12, 2011
13
CA
Hi

So i need a macro that locates the bold data come right after each other from a column ("D")
then combines them in the cell next to them in column "C"
and it keeps doing it for the next set of bold data that come right after each other

thanks
 
I'm sorry if i wasn't clear enough on my question
i'm new to VBA and to these forums

so here is what im looking for

before:
C D
rdx acura rdx
rdx acura acura

after:
corolla toyota 2011 corolla
corolla toyota 2011 toyota
corolla toyota 2011 2011


ive been trying find a way of doing this using vba the whole day but so far haven't found anything
its my first time using vba so your help would be much appreciated

Thanks
 



Your example makes absolutely no sense.

There is no logical connection between the before and after.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
sorry theres a mistake in my previous comment...heres the correct example

before:

C D
rdx
acura

after:

C D
rdx acura rdx
rdx acura acura
 


are these contiguous cells?

what if not all the cells are bold?

what is the business case for this requirement?

Please answer ALL these questions.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
yes the cells are contiguous

and there might be cells that are not bold...in this case it should not select those...i actually need it to recognize only the bold ones and as soon as the macro come across a non-bold cell, it should stop there and not concatenate the data...then keep detecting other bold cells that are found further down in that column and do the same process again..i hope im not confusing you

im trying to create a macro that will help commercial auto analysts reformat the data that they get in the format that they need it to be...they usually do it manually but it takes so much time...im working as a coop student in an insurance company
 


try this
Code:
Sub test()
    Dim rng As Range, r As Range, sOUT As String
    
    Set rng = Intersect(Cells(1, "D").EntireColumn, ActiveSheet.UsedRange)

    For Each r In rng
        With r
            If .Font.Bold Then
                sOUT = sOUT & .Value & " "
            End If
        End With
    Next

    sOUT = Left(sOUT, Len(sOUT) - 1)

    For Each r In rng
        With r
            If .Font.Bold Then
                With .Offset(0, -1)
                    .Value = sOUT
                    .Font.Bold = True
                End With
            End If
        End With
    Next
    
    Set rng = Nothing
End Sub


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
thanks for the help skip! im closer to what im looking for but it's not exactly it...right now it is taking ALL the bold data and putting them together in the cells in column C...
here is what it should do

before:

C D
acura
rdx
4 wheels


toyota
corolla
4 wheels
2000 hd diesel


calibre
van
4 wheels

after:

C D
acura rdx acura
acura rdx rdx
acura rdx 4 wheels

toyota corolla toyota
toyota corolla corolla
toyota corolla 4 wheels
toyota corolla 2000 hd diesel

caliber van calibre
caliber van van
caliber van 4 wheels



so basically it has to concatenate only the bold data that is relevant for each non-bold data...so here the first relevant data for the "4 wheels" is acura rdx

when it reaches the blank rows it stops...

goes to the next set of data...concatenates the bold data again which is toyota corolla and pastes it next to the unbold data "4-wheels" and "2000 hd diesel"

and again for the calibre van

and i already have a macro that will clear the rows which won't be necessary... like

acura rdx acura
acura rdx rdx

toyota corolla toyota
toyota corolla corolla

caliber van calibre
caliber van van


i should have been more clear the first time...sorry about that

thanks for your help...appreciate it :)
 



This is what happens when you are not forthcoming with a CLEAR, CONSICE & COMPLETE description of your issues.

Now we have multiple groups!

It would have been helpful to YOU and other contributors, if you would have described your need as you did in the previous post, rather than the scant, stingy information you initially disclosed.

Since this is a more significant VBA solution, please repost your question in forum707, with a full explanation of your problem.


Please include the code that has already been provided to you as a partial solution.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top