Putting a text after a specific cell

jamongkim

New Member
Joined
Sep 29, 2017
Messages
7
Hi! please help me to figure out on how to put a text if only nothing follows to the word "TRIMFORM". below is the code that I used. Thanks in advance :)

Sub try()
Dim c As Range
For Each c In Range("D2:D429")
If c.Value Like "*TRIMFORM*" Then
c.Offset(1, 0).EntireRow.Insert
c.Offset(1, 0).Value = "Epoxy"
End If
Next c
End Sub


 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to the board. Do you mean:
Code:
IF c.Value = "TRIMFORM" Then
Your code is using LIKE *TRIMFORM* which finds any cell that contains TRIMFORM in it's value.
C.Value = "TRIMFORM" is testing when it exactly equals "TRIMFORM"
 
Upvote 0
I will remove like? I'm sorry. I just started learning the vb on excel. The word epoxy should only be added if nothing follows or a blank cell to the word trimform
 
Upvote 0
I will remove like? I'm sorry. I just started learning the vb on excel. The word epoxy should only be added if nothing follows or a blank cell to the word trimform
 
Upvote 0
Try changing:
Rich (BB code):
If c.Value Like "*TRIMFORM*" Then

To
Rich (BB code):
Rich (BB code):
Rich (BB code):
If c.Value = "TRIMFORM" Then
 
Upvote 0
https://ibb.co/gqQ2Ow

Please see my captured result of the code you suggested, I want the results to be just the second encircled one. I don't need to add epoxy if there is already a word after trimform which is like the first encirlced one. Pls help me. TIA! :)
 
Upvote 0
How about
Code:
Sub try()
Dim c As Range
For Each c In Range("D2:D429")
    If c.Value Like "FOXG1" And c.Offset(1) = "" Then
        c.Offset(1, 0).EntireRow.Insert
        c.Offset(1, 0).Value = "Epoxy"
    End If
Next c
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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