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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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