Macro to convert rows with tonnes inputs to kilograms

lekh0602

New Member
Joined
Jul 9, 2014
Messages
33
Hi,

I have specific columns where I input values manually - the rows are constant so always from B11 to Q38 and down to row 72 (B-Q). The inputs are values in tonnes that I would like to convert to kilograms by adding three 0. However, some of the cells are also text cells which should not have the three 0s added. Will it be possible to create a macro that auto fill every number cell with "000" but not to any text cell?

Any assistance in this matter is highly appreciated.

Thanks! :)
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I am sorry - my mistake. I mean two tables: B11:Q30 and B38:Q71.

Can I just add an extra code to the specific worksheet? So one for the one range and to the other range?
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Range("B11:Q30,B38:Q71")) Is Nothing Then
    Application.EnableEvents = False
    For Each c In Target
        If IsNumeric(c.Value) Then c.Value = c.Value * 1000
    Next c
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,670
Members
449,463
Latest member
Jojomen56

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