zookeepertx
Well-known Member
- Joined
- May 27, 2011
- Messages
- 589
- Office Version
- 365
- Platform
- 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:
I really appreciate any help!
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!