Cut paste anything that is not bold

excelvbanoob420

New Member
Joined
Oct 5, 2022
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello,

I need help with a macro which will cut & paste the text to the next column if its not bold as shown below:

Input:

IDTypeText
1​
FruitLorem Ipsum
2​
VegetablesContrary to popular belief,
3​
Fruitgoing to use a passage
4​
FruitLorem Ipsum generators on the Internet
5​
Vegetablesres, to generate Lorem Ipsum
6​
Vegetablesfor those interested
7​
Vegetablesgoing through the cites of the word
8​
Vegetableschunk of Lorem Ipsum used
9​
Vegetablesgenerator on the Internet


Output:
1. Change the column name from Text -> Text format
2. Create a new column called 'Parsed Text' which will have the text that is not bold and the bold items will be replaced with Fixedtext.

IDTypeText formatParsed Text
1​
FruitLorem IpsumFixedtext
2​
VegetablesContrary to popular belief,
3​
Fruitgoing to use a passage
4​
FruitLorem Ipsum generators on the InternetFixedtext
5​
Vegetablesres, to generate Lorem IpsumFixedtext
6​
Vegetablesfor those interested
7​
Vegetablesgoing through the cites of the wordFixedtext
8​
Vegetableschunk of Lorem Ipsum used
9​
Vegetablesgenerator on the InternetFixedtext

Thanks in advance
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hello,

I need help with a macro which will cut & paste the text to the next column if its not bold as shown below:

Input:

IDTypeText
1​
FruitLorem Ipsum
2​
VegetablesContrary to popular belief,
3​
Fruitgoing to use a passage
4​
FruitLorem Ipsum generators on the Internet
5​
Vegetablesres, to generate Lorem Ipsum
6​
Vegetablesfor those interested
7​
Vegetablesgoing through the cites of the word
8​
Vegetableschunk of Lorem Ipsum used
9​
Vegetablesgenerator on the Internet


Output:
1. Change the column name from Text -> Text format
2. Create a new column called 'Parsed Text' which will have the text that is not bold and the bold items will be replaced with Fixedtext.

IDTypeText formatParsed Text
1​
FruitLorem IpsumFixedtext
2​
VegetablesContrary to popular belief,
3​
Fruitgoing to use a passage
4​
FruitLorem Ipsum generators on the InternetFixedtext
5​
Vegetablesres, to generate Lorem IpsumFixedtext
6​
Vegetablesfor those interested
7​
Vegetablesgoing through the cites of the wordFixedtext
8​
Vegetableschunk of Lorem Ipsum used
9​
Vegetablesgenerator on the InternetFixedtext

Thanks in advance
Also, one more thing the macro should work irrespective of the number of rows
 
Upvote 0
Give this a try.
It will create a new sheet with the original name and a number after it.

VBA Code:
Sub MoveUnbolded()

    Dim shtOrig As Worksheet, shtNew
    Dim lrowNew As Long, irow As Long
    
    Set shtOrig = ActiveSheet
    shtOrig.Copy after:=shtOrig
    Set shtNew = ActiveSheet
    
    With shtNew
        lrowNew = .Cells(Rows.Count, "C").End(xlUp).Row
    End With

    For irow = 2 To lrowNew
        With shtNew.Range("C" & irow)
            If .Font.Bold = False Then
                .Offset(, 1).Value = .Value
                .ClearContents
            Else
                .Offset(, 1).Value = "FixedText"
            End If
        End With
    Next irow
    
    With shtNew.Range("C1")
         .Value = "Text format"
        .Offset(, 1).Value = "Parsed Text"
        .Offset(, 1).EntireColumn.AutoFit
    End With

End Sub
 
Upvote 0
Solution
Or, overwrite exist data:
VBA Code:
Option Explicit
Sub test()
Dim cell As Range
For Each cell In Range("C2:C" & Cells(Rows.Count, "C").End(xlUp).Row)
    If Not cell.Font.Bold Then
        cell.Cut cell.Offset(, 1)
    Else: cell.Offset(, 1).Value = "Fixed Text"
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top