Using VBA to add a text string to original cell contents - HELP

Koofrith

New Member
Joined
Jun 21, 2016
Messages
6
Hi,

I've been using VBA to add the text ''Waxcap'' to a cell where the If function meets the conditions of a certain set of values being found in cells of the same row in a different column.

This is my code when conditions are met:

Then Cells(i, designations).Value = "Waxcap; " & Cells(i, designations).Value
End If

This works fine when the cell in the designations column is blank (I get the value "Waxcap;" returned). But when there is already a value in the cell in the designations column then I only get the original value returned, and it does not add "Waxcap;".

Thank you for your help
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
This should return 'Waxcap;' followed by whatever was originally in the cell.
Code:
Cells(i, designations).Value = "Waxcap; " & Cells(i, designations).Value

Is there any other code?
 
Upvote 0
This should return 'Waxcap;' followed by whatever was originally in the cell.
Code:
Cells(i, designations).Value = "Waxcap; " & Cells(i, designations).Value

Is there any other code?

Hi Norie, This is the full code:

' waxcaps
If (Cells(i, latinName).Value) Like "Hygrocybe*" Or (Cells(i, latinName).Value) Like "Entoloma*" Or (Cells(i, latinName).Value) Like "Clavaria*" Or (Cells(i, latinName).Value) Like "Microglossum*" Or (Cells(i, latinName).Value) Like "Geoglossum*" Or (Cells(i, latinName).Value) Like "Dermoloma*" Or (Cells(i, latinName).Value) Like "Porpoloma*" Or (Cells(i, latinName).Value) Like "Camarophyllopsis*" Or (Cells(i, latinName).Value) Like "Clavulinopsis*" Or (Cells(i, latinName).Value) Like "Ramariopsis*" Or (Cells(i, latinName).Value) Like "Trichoglossum*" Or (Cells(i, latinName).Value) Like "Glutinoglossum*" Or (Cells(i, latinName).Value) Like "Cuphophyllus*" Then Cells(i, designations).Value = "Waxcap; " & Cells(i, designations).Value
End If
 
Upvote 0
Is designations definitely referring to the correct column?
 
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