Change values in unknown range

KLund1

Board Regular
Joined
Oct 27, 2005
Messages
64
I have a unknown range of a constant value. I do not know the start row, or how many rows of the constant value there are, but they are continuous in the column. I need to change the values 2 columns over from positive to negative that are on the same row as the constant value.
Anyone have some VBA code that can do this?
Thanks everyone. Lots of good help here !!! :)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks for the reply.
Yes. The constant value(24650.0) in column D, column F is where the values I want to change the sign.
 
Upvote 0
something like this?:
Code:
Sub blah2()
Dim xxx As Range
Set xxx = Columns("D").Find(what:=24650, LookIn:=xlFormulas, lookat:=xlWhole)
If Not xxx Is Nothing Then
  Do
    xxx.Offset(, 2).Value = -xxx.Offset(, 2).Value
    Set xxx = xxx.Offset(1)
  Loop Until xxx <> 24650
End If
End Sub
 
Upvote 0
You don't need a macro:

1, Create two sheets (sheet1 and sheet2). On "sheet2" is where your constants are located.

2. On "Sheet1" place the following equation into cell A1 "=IF(Sheet2!A1=0,"",-Sheet2!A1)"

3. Copy cell A1 on "Sheet1" highlight all potential cells the constant could potentially go to there has to be a max. Maybe the max of excel is what you want; however there has to be a max. Example: A1:KJ75.

4. Once the max range is selected paste special formulas.

Done your numbers are all converted to negatives and zero's are blank if you want it to show zero change "" to 0.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

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