VBA check if last character in a cell is punctuation

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
Hello

I need code to check if a last character in a cell is an exclamation.

Example

B!

If the last character in a cell is an exclamation, I then need to multiply a range of cells below it by 0.0001.
(I'm changing values in the range from ppm to %)

Make this

B!
3
6
22
120

Look like this

B!
0.0003
0.0006
0.0022
0.0120

Thanks for any help
Tom
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Here is one way:
Code:
Sub MyMacro()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    If Right(Range("A1"), 1) = "!" Then
        For Each cell In Range("A2:A5")
            cell = cell * 0.0001
        Next cell
    End If
    
    Application.ScreenUpdating = True
    
End Sub
Change the ranges to suit your needs.
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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