1: You are absolutely correct, of coarse. Statements shouldn't be 'shortened', as mine was.
No doubt some future version will take exception to what today does work.
I'll pass that on to the guru who initially supplied me with this code.
2: As above
3: Named Range. EACH time the macro is run, it is applied to a different data base, with a different number of rows, within the same workbook. Consequently, the formulas do NOT work correctly, since it appears to always reference the original (first) named range.
For example, if the first time I run the macro it indicates that there are 10 rows in use, that is what the named range will refer to.
The next the macro is run, the data could consist of 250 rows, yet this formula will be dividing 10, not by 250, as required.
I hope that makes it a bit clearer.
4: Sorry! I did try R5C26 with and without quotes.
With quotes I get run time error 1004; Method 'Range' of object'_Global' failed.
Without quotes I get Compile Error: Variable not Defined
5: I hope the above clears this one up.
The following shows the macro in question, without all the duplicates used to operate on the multiple columns.
Perhaps that might also help clear up what I'm obviously not expressing very well or perhaps you might see what in my code is perhaps tripping me up.
Thanks for your consideration.
Sub UCDB_STEP_G2()
' Enter Formulas in first blank cell at bottom of each of the following columns
Dim lastrow As Long
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Cells(lastrow + 1, "Z").Formula = "=Sum(Z6:Z" & lastrow & ")"
Cells(lastrow + 1, "AC").Formula = "=Sum(AC6:AC" & lastrow & ")"
Cells(lastrow + 1, "AH").Formula = "=Sum(AH6:AH" & lastrow & ")"
Cells(lastrow + 1, "AI").Formula = "=Sum(AI6:AI" & lastrow & ")"
' ETC............
' Go to AU6, then down 1 row past end, Insert Formula, and Format
Range("AU6").End(xlDown).Offset(1, 0).Select
ActiveCell.Formula = "=RC[-7]-RC[-1]"
' ETC............
' Set up Bottom most row with Formulas, and with Formatting
' >>>>>> Here is where the fun starts.............
' First, my original working statement
lastrow = Cells(Rows.Count, "AT").End(xlUp).Row
Cells(lastrow + 1, "AT").Formula = "=R[-1]/NoOfUnits"
' Modified to fix the lack of column reference.
Cells(lastrow + 1, "AT").Formula = "=R[-1]C/NoOfUnits"
lastrow = Cells(Rows.Count, "Z").End(xlUp).Row
Cells(lastrow + 1, "Z").Formula = "=R[-1]/" & Range("Z5").Value
lastrow = Cells(Rows.Count, "AC").End(xlUp).Row
Cells(lastrow + 1, "AC").Formula = "=R[-1]/" & Range("Z5").Value
lastrow = Cells(Rows.Count, "AH").End(xlUp).Row
Cells(lastrow + 1, "AH").Formula = "=R[-1]/" & Range("Z5").Value
lastrow = Cells(Rows.Count, "AI").End(xlUp).Row
Cells(lastrow + 1, "AI").Formula = "=R[-1]/" & Range("Z5").Value
' ETC..............
lastrow = Cells(Rows.Count, "AV").End(xlUp).Row
Cells(lastrow + 4, "AV").Formula = "Range: High"
Cells(lastrow + 5, "AV").Formula = "Range: Low"
Cells(lastrow + 6, "AV").Formula = "Range: DIFF"
Cells(lastrow + 7, "AV").Formula = "Range: Plus"
Cells(lastrow + 8, "AV").Formula = "Range: Neg"
Cells(lastrow + 4, "AX").Formula = "=MAX(AX6:AX" & lastrow & ")"
Cells(lastrow + 5, "AX").Formula = "=MIN(AX6:AX" & lastrow & ")"
Cells(lastrow + 4, "AX").Formula = "=Countif(AX6:AX" & lastrow & ", " & """>0""" & ")"
Cells(lastrow + 5, "AX").Formula = "=Countif(AX6:AX" & lastrow & ", " & """<0""" & ")"
End Sub
Bookmarks