Posted to microsoft.public.excel.programming
|
|
I have no Idea how to do this in Macro.. or if it can even be done easily
thanks a bunch bernie
Bernie Deitrick wrote:
Ray,
Select the cells (below the cell with the formula) that you want to autofill - do not select the
cell with the formula - and run the macro below.
Just as a disclaimer, the macro will increment the column letter of the first range in the formula,
which must be an absolute (uses $) multi-row single column range. Otherwise, bad things will happen
;-).
HTH,
Bernie
MS Excel MVP
Sub TryNow()
Dim myStr As String
Dim myCol1 As String
Dim myCol2 As String
Dim myCell As Range
For Each myCell In Selection
myStr = myCell(0, 1).Formula
myCol1 = ColLet(myStr)
myCol2 = ColLet(Range(myCol1 & "1")(1, 2).Address)
myStr = Replace(myStr, "$" & myCol1, "$" & myCol2, 1, 2)
If myCell(0, 1).HasArray Then
myCell.FormulaArray = myStr
Else
myCell.Formula = myStr
End If
Next myCell
End Sub
Function ColLet(FormStr As String) As String
Dim mySplit As Variant
mySplit = Split(FormStr, "$")
ColLet = mySplit(LBound(mySplit) + 1)
End Function
Thanks for your help guys. This is what I am working with. The problem is:
[quoted text clipped - 23 lines]
Thanks again folks!!!!!
--
Message posted via http://www.officekb.com
|