Fairly new to VBA. I have a macro that I'd like to change to be able to work on however many rows containing data are in the worksheet rather than the hardcoded value (46).
Sub test1calc() ' ' test1calc Macro ' ' '1 - UNSTRESSED POSTED PRODUCT LEVEL BREAKDOWN SUMMED AT NETTING SET Columns("AS:AS").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Range("AS1").Select Selection.Interior.Pattern = xlSolid Selection.Interior.PatternColorIndex = 2 Selection.Interior.Color = 65535 ActiveCell.FormulaR1C1 = "Unstressed Posted Total" Range("AS2").Select ActiveCell.FormulaR1C1 = "=SUM(RC[-30]:RC[-1])" Range("AS2").Select Selection.AutoFill Destination:=Range("AS2:AS46") Range("AS2:AS46").Select ActiveSheet.Calculate Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False End Sub
"however many rows are in the worksheet"do you mean the number of rows relative to some existing data? Surely you don't want to fill millions of rows?