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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
antony

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

strVal = "Without full stop"

MsgBox strVal

strVal = strVal & "."

MsgBox strVal
 

patrickmuldoon99

Active Member
Joined
Jun 27, 2006
Messages
345
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
 

Forum statistics

Threads
1,141,847
Messages
5,708,934
Members
421,599
Latest member
santosh234

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
Top