Changing the value of some cells to negative numbers

zookeepertx

Well-known Member
Joined
May 27, 2011
Messages
589
Office Version
  1. 365
Platform
  1. Windows
Hi there,
I just LOVE this board; it's so educational!

I've got a macro that works for a particular spreadsheet, but part of it runs a bit slowly & I don't know why. A lot of the macro is just formatting & moving columns around, but here's what the slow part does: Column H contains a number - always either 18 or 35. Column I contains a dollar value, but the report shows all the values as positive numbers. Any rows with 18 in Col H need to be a negative value in Col I. This report is a different length every time it's run.

I've got other, way more complicated macros on sheets of 1000 or more rows that will finish in just a second or two, but just this portion of this macro takes about 30 seconds on a report of about 500 rows. I'm sure there's a way to speed it up, but I don't know what it is. (Personally, I'm REALLY proud of having just figured out how to get it to do what I want at ALL, LOL!) Can anybody tell me how to get this to run faster?

Here's my code for that part of the macro:

Code:
    nRow = 2
    Do While Not IsEmpty(Cells(nRow, 1).Value)
        Range("I:I").Select
        Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
            If ActiveSheet.Cells(nRow, 8).Value = 18 Then
                ActiveSheet.Cells(nRow, 9).Value = (Cells(nRow, 9) * -1)
            End If
        nRow = nRow + 1
    Loop

I really appreciate any help!
 
Yeah, you’re right. I was just in a hurry & didn’t take the time to find this thread again; don’t know why. Sorry about that and thanks once more for your terrific help!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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