VBA - To look at data in one column/cell then put something into another column/cell

jezvanderbrown

New Member
Joined
Nov 26, 2013
Messages
11
Can anyone help me in creating a VBA/macro please as I'm not sure how to go about it. It would really help...

The below link/picture is the data i have.
https://www.dropbox.com/s/1hzdoqja61seyhs/Capture1.JPG

I want the macro to look at column C and put one of the following in the cell next to it in column D;

if there is a + in a Cell in column C then put the word 'Broad' in the cell next to it in column D.

if there is only 1 word in a cell in column C whether it contains a + or not, then put the word 'Broad' in the cell next to it in column D.

if there is 2 or more words in a cell in column C and it doesn't contain a + then put the word 'Phrase' in the cell next to it in column D.


What i want the macro to achieve is in the below link/picture.
https://www.dropbox.com/s/n3159s5532c1h0p/Capture2.JPG

Many Thanks :)

Jez
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You can try this, let me know how you get on.

Code:
Option Explicit

Sub test()
Dim Rng As Range, i As Range


With ActiveSheet
    Set Rng = .Range("C2:C" & .Range("C" & Rows.Count).End(xlUp).Row)
    For Each i In Rng
        If InStr(1, i.Text, "+", 1) > 0 Or InStr(1, i.Text, " ", 1) = 0 Then
        i.Offset(0, 1).Value = "Broad"
        Else
        i.Offset(0, 1).Value = "Phrase"
        End If
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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