Excel VBA: Add multiplier to column without iterations or modifying outside column.

Is there a one step VBA method for adding a multiplier to all numbers in range("C2:C100") WITHOUT iterations or modifying any cell outside range("C2:C100")

Example: Multiply all numbers in column C by 20.
*I have considered: sheets("Sheet2").range("C2:C100").formula = "=C2*20" nonetheless, the formula copies over the values before they are calculated.
ouestqueAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Did you mean this to be about Excel rather than Access?
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
my question too, Martin!

yes, in Excel, you can adjust all numbers in a column like this:

1. copy what you want to add, subtract, multiply, or divide by
2. select range to change
3. Paste Special -- multiply
4. OK

original:
1
2
3
4
5
6
7
8
9
10

changed:
20
40
60
80
100
120
140
160
180
400

have an awesome day,
crystal
0
ShumsExcel & VBA ExpertCommented:
If its excel you may try below code:
Sub AddMultiplier()
Dim Ws As Worksheet
Dim Rng As Range, c As Range
Set Ws = Worksheets("Sheet2")
Set Rng = Ws.Range("C2:C100")
Application.ScreenUpdating = False
For Each c In Rng
    c.Value = c.Value * 20
Next c
Application.ScreenUpdating = True
End Sub

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
here is a screenshot for the example I gave above:
Excel - Paste Special - Multiply all numbershave an awesome day,
crystal
0
Jorge PaulinoIT Pro/DeveloperCommented:
With VBA you cannot do that with just one line
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
To do this with VBA, you can iterate* through a selection. Then you don't have to know the sheet or range -- perhaps use InputBox to ask what number and operation.  Please explain more about what you are doing.  

* no way to get around iterating because the formula/value is different each time
0
Rgonzo1971Commented:
Hi,

pls try
Sheets("Sheet2").Range("C2:C100").Value = Evaluate("=IF((C2:C100)*20,C2:C100*20,"""")")

Open in new window

Regards
2
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
cool, didn't know you could do that!
0
Rgonzo1971Commented:
if you have also text in your range then try
Sheets("Sheet2").Range("C2:C100").Value = Evaluate("=if(ISNUMBER(C2:C100),C2:C100*20,IF(C2:C100<>"""",c2:c100,""""))")

Open in new window

0
ShumsExcel & VBA ExpertCommented:
If your concern is to show formula in specified range instead of values, you may try below:
Sub AddMultiplier()
Dim Ws As Worksheet
Dim Rng As Range
Set Ws = Worksheets("Sheet2")
Set Rng = Ws.Range("C2:C100")
Application.ScreenUpdating = False
For Each c In Rng
    c.Formula = "=" & c & "*20"
Next c
Application.ScreenUpdating = True
End Sub

Open in new window

0
ShumsExcel & VBA ExpertCommented:
Rgonzo Sir,

I believe OP mentioned
Example: Multiply all numbers in column C by 20.

Its not just C2 value to be multiplied in all the cells in specific range.
0
Rgonzo1971Commented:
@Shums it multiplies every cell of C2:C100 (array formula)
0
Rgonzo1971Commented:
of course if you activesheet is not Sheet2 then try
Sheets("Sheet2").Range("C2:C100").Value = Evaluate("=if(ISNUMBER(Sheet2!C2:C100),Sheet2!C2:C100*20,IF(Sheet2!C2:C100<>"""",Sheet2!c2:c100,""""))")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ouestqueAuthor Commented:
Wow!!! That is amazing. Very Very Cool!!! Thank you so much!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.