VBA: Multiply Entire Column by a Number

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,214
Office Version
  1. 365
Platform
  1. Windows
I would like to multiply the values in column K by .05. I tried something like this but says invalid use of property.

Code:
Set TBSheet = Sheets("TestBefore")
TBSheet.Range ("K")
.Value = Evaluate(.Address & "*.05")

P.S. I'm not sure what .address above indicates.
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Also tried the following but did not work:

Code:
Set TBSheet = Sheets("TestBefore")
TBSheet.Range ("K").Value *.05
 
Last edited:
Upvote 0
Try this.
Code:
With TBSheet.Range("K:K")
    .Value = Evaluate("INDEX(" & .Address & "*.05,,1)")
End With

PS That code will multiply every cell in the column, even empty cells which will end up with 0 in them.
 
Upvote 0
You need to use the correct address for a full column as well as the With construction
Code:
    With Range("K:K")
        .Value = Evaluate(.Address & "*.05")
    End With
 
Upvote 0
Hi,

Enter 0.05 in some unused cell, M1 for example.

Code:
    Range("M1").Copy
    Range("K1:K100").PasteSpecial xlPasteValues, xlPasteSpecialOperationMultiply

Change references to match your data.
 
Upvote 0
Try this.
Code:
With TBSheet.Range("K:K")
    .Value = Evaluate("INDEX(" & .Address & "*.05,,1)")
End With


PS That code will multiply every cell in the column, even empty cells which will end up with 0 in them.

Ok - How can I have it start from K2 to the last row of data?
 
Upvote 0
I was able to get it to start from K2, but it multiplies past the last row still. Not sure what I'm doing wrong. Here is the revised code:

Code:
ith TBSheet.Range("K2", TBSheet.Cells(Rows.Count, "K").End(xlDown))
    .Value = Evaluate("INDEX(" & .Address & "*.01,,1)")
    End With
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,222,108
Messages
6,163,972
Members
451,867
Latest member
csktwyr

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