jardenp
Active Member
- Joined
- May 12, 2009
- Messages
- 373
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
My macro code is doing a slow hang when I try to extend the formulas in I2 and J2 down through however many rows there are. It only does this when row 2 is the last row, i.e., when there is only 1 row of data below the header labels. By "slow hang" I mean the progress bar pops up, you can tell it's working through something. Then the values in I2 and J2 appear briefly in each cell in columns I and J and then disappear. Here's my code:
I use "Range("XX").End(xlDown).Row" all the time to find the last row and I've never had problems before. Is this a technique that is not suited to instances where you can't extend--where the row in the code (here row 2) is the final row?
Thanks!
Code:
'Format fields - Change Product code, Quantity, and Pump# for copied rows
'Product
Range("I2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(RC[-8]>0,2,"""")"
'Quantity
Range("J2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-9]>0,RC[17],"""")"
Range("I2:J2").Select
Selection.AutoFill Destination:=Range("I2:J" & Range("A2").End(xlDown).Row), Type:=xlFillDefault
I use "Range("XX").End(xlDown).Row" all the time to find the last row and I've never had problems before. Is this a technique that is not suited to instances where you can't extend--where the row in the code (here row 2) is the final row?
Thanks!