Adding a full stop to a string in vb

apgriffiths

Board Regular
Joined
Jun 2, 2006
Messages
99
Hi all

I want my code to look at certain text entries and then add a full stop to the very end of the string. Can anyone help??

Antony
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
antony

Why not just use something like this?
Code:
Dim strVal

strVal = "Without full stop"

MsgBox strVal

strVal = strVal & "."

MsgBox strVal
 
Upvote 0
If the cell is [A1]

Code:
[A1] = [A1].value & "."

You could add conditions to this such as :

Code:
If [A1] = "Hello World" then
[A1] = [A1] & "." 
else
[A1] = [A1] & "!"
end if

The above code will add an exclamation mark if the string is not equals to "Hello World", and will add a full stop if it is.

HTH

Patrick
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,176
Members
448,948
Latest member
spamiki

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