G
GettingThere
Sorry for starting a new thread, but I have a new problem:
How can I make the formulas below always look at column A? I don't know in
advance what column I am going to be working with, so I am getting incorrect
column references with the following:
Sub inputToLastColumnTESTER3()
Dim colNum As Integer
Dim lstRow As Integer
Dim frmRow As Integer ' lst row for formula
Dim i As Integer
Dim rng As Range
Dim newRng As Range
Dim Formula1 As String
Dim Formula2 As String
Dim Formula3 As String
Set rng = Cells(1, "IV").End(xlToLeft) ' get last used column
'Debug.Print "Lst column is " & rng.Address
Set newRng = rng.Cells(1, 2).Resize(1, 1) 'range to input next - not used yet
' Debug.Print "new range is " & newRng.Address
colNum = rng.Column + 1
lstRow = Range("a" & Rows.Count).End(xlUp).Row
frmRow = lstRow - 2
' Debug.Print "column index is " & colNum & " lstRow is
" & lstRow
Formula1 = "=SUM(RC[-3]:RC[-2])" ' HOW TO MAKE ALWAYS REFER TO COL A ??
Formula2 = "=RC[-3]*RC[-2]"
Formula3 = "=RC[-3]/RC[-2]"
For i = 1 To frmRow Step 3
Cells(i, colNum).FormulaR1C1 = Formula1
Cells(i + 1, colNum).FormulaR1C1 = Formula2
Cells(i + 2, colNum).FormulaR1C1 = Formula3
Next i
End Sub
ORIGINAL THREAD FOLLOWS:
Other than doing a copy and paste, that seems OK.
How can I make the formulas below always look at column A? I don't know in
advance what column I am going to be working with, so I am getting incorrect
column references with the following:
Sub inputToLastColumnTESTER3()
Dim colNum As Integer
Dim lstRow As Integer
Dim frmRow As Integer ' lst row for formula
Dim i As Integer
Dim rng As Range
Dim newRng As Range
Dim Formula1 As String
Dim Formula2 As String
Dim Formula3 As String
Set rng = Cells(1, "IV").End(xlToLeft) ' get last used column
'Debug.Print "Lst column is " & rng.Address
Set newRng = rng.Cells(1, 2).Resize(1, 1) 'range to input next - not used yet
' Debug.Print "new range is " & newRng.Address
colNum = rng.Column + 1
lstRow = Range("a" & Rows.Count).End(xlUp).Row
frmRow = lstRow - 2
' Debug.Print "column index is " & colNum & " lstRow is
" & lstRow
Formula1 = "=SUM(RC[-3]:RC[-2])" ' HOW TO MAKE ALWAYS REFER TO COL A ??
Formula2 = "=RC[-3]*RC[-2]"
Formula3 = "=RC[-3]/RC[-2]"
For i = 1 To frmRow Step 3
Cells(i, colNum).FormulaR1C1 = Formula1
Cells(i + 1, colNum).FormulaR1C1 = Formula2
Cells(i + 2, colNum).FormulaR1C1 = Formula3
Next i
End Sub
ORIGINAL THREAD FOLLOWS:
Other than doing a copy and paste, that seems OK.