How to multiply the values within the conditional formatting range?

sneakikaz

New Member
Joined
Jun 8, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have a big data excel file, there are many negative numbers. Now I want to highlight all the negative values and then multiply it with a specific number (for example 0.5). Could you kindly show me how to do it?
Thank you.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
What does the "big data excel file" mean? Big range of data in single sheet, or medium range of data in lot of sheets?
 
Upvote 0
I think you can use format cell to highlight the negative values and after that, you can use "IF" to multip with which number you want.
Supposedly A column is your data-> B1= If(A1<0,A1*0.5,"")
 
Upvote 0
It took 6s for range "A1:ZZ10000" (10,000 rows * 702 columns)
Does it annoy too much?

VBA Code:
Option Explicit
Sub multifly()
Dim i&, j&, lcell As Range, rng, n, t
t = Timer
n = 0.5
Set lcell = ActiveSheet.UsedRange.SpecialCells(xlLastCell)
rng = Range("A1", lcell).Value
For i = 1 To lcell.Row
    For j = 1 To lcell.Column
        If rng(i, j) < 0 Then rng(i, j) = rng(i, j) * n
    Next
Next
Range("A1", lcell).Value = rng
MsgBox Timer - t
End Sub
 
Upvote 0
It took 6s for range "A1:ZZ10000" (10,000 rows * 702 columns)
Does it annoy too much?

VBA Code:
Option Explicit
Sub multifly()
Dim i&, j&, lcell As Range, rng, n, t
t = Timer
n = 0.5
Set lcell = ActiveSheet.UsedRange.SpecialCells(xlLastCell)
rng = Range("A1", lcell).Value
For i = 1 To lcell.Row
    For j = 1 To lcell.Column
        If rng(i, j) < 0 Then rng(i, j) = rng(i, j) * n
    Next
Next
Range("A1", lcell).Value = rng
MsgBox Timer - t
End Sub
chỉ cần chính xác với đủ dữ liệu là được, thời gian không quan trọng ạ.
 
Upvote 0
Have you given it a shot?
And, does it work?
Not yet, I will try it after finishing the remaining work and tell you. Moreover, the speed is not important, I only need the accuracy and to make sure every negative number is multiplied.
 
Upvote 0
Have you given it a shot?
And, does it work?
Sub multifly()
Dim i&, j&, lcell As Range, rng, n, t
t = Timer
n = 0.85
Set lcell = ActiveSheet.UsedRange.SpecialCells(xlLastCell)
rng = Range("B1", lcell).Value
For i = 1 To lcell.Row
For j = 1 To lcell.Column
If -25 < rng(i, j) < -15 Then rng(i, j) = rng(i, j) * n
Next
Next
Range("A1", lcell).Value = rng
MsgBox Timer - t
End Sub

When I try with the range from -25 to -15 , it said out of range and when I pressed debug, the error appeared in the underlined are above.
 
Upvote 0
Replace
If -25 < rng(i, j) < -15 Then
by
If rng(i, j)>-25 And rng(i,j) < -15 Then
 
Upvote 0
Still having the same problem, I will attach an image below for you. I want to multiply the conditional number in column B.
1659595621739.png
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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