VBA for the whole number

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
1,019
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

i need to round up the value where on column 3 and 6 and for entire column.
this is an example I have more colunm 3,6,9 and so on. all number I need It in whole number

book1
DEFGHI
1020.1%25.2%5.1%29.8%27.5%-2.3%
1130.9%38.7%-22.5%38.2%44.0%5.8%
1271.0%72.6%1.6%73.1%78.1%5.0%
1346.1%55.0%8.9%42.6%58.5%16.0%
1418.3%22.2%4.0%11.2%22.7%11.5%
159.0%20.5%11.4%10.6%22.4%11.8%
Sheet2
 
Just to be clear, you always want to round up? So 5.1% should be 6%?
Is there a last column or do we need to determine that in code?
 
Upvote 0
Just to be clear, you always want to round up? So 5.1% should be 6%?
Is there a last column or do we need to determine that in code?
Hi Sir,

I need the whole number if 5.1 then it should be 5 only along for every 3,6,9 and so on column
22.5 means 23 number

Regards
Sanjeev
 
Upvote 0
VBA Code:
Sub WholeNumbers()
Dim lc As Long, r As Long, c As Range
lc = Range("XFD1").End(xlToLeft).Column
For r = 3 To lc Step 3
    For Each c In Range(Cells(1, r), Columns(r).End(xlDown))
        If IsNumeric(c) And c <> "" Then c = Round(c * 100, 0)
    Next
Next
End Sub
 
Upvote 1
Solution
VBA Code:
Sub WholeNumbers()
Dim lc As Long, r As Long, c As Range
lc = Range("XFD1").End(xlToLeft).Column
For r = 3 To lc Step 3
    For Each c In Range(Cells(1, r), Columns(r).End(xlDown))
        If IsNumeric(c) And c <> "" Then c = Round(c * 100, 0)
    Next
Next
End Sub
Wonderful..!!!!Thank you so much sir for your help in this :)
 
Upvote 0

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