close

Dear all,

Someone has designed a macro for me which should perform a linear
extrapolation on gaps in my dataset.

However, it appears to work across the rows as opposed to down the
columns. I require it to work on columns F-I and R-U (inclusive) as
opposed to the whole dataset.

Would anybody be able to correct the macro below to achieve this?Sub Pfil()

Dim i As Long
Dim r As Long
Dim er As Long
Dim sc As Long
Dim ec As Long
Dim src As Range
Dim dest As Range

'Start Row
r = 2
'Last row
er = Range(quot;a65536quot;).End(xlUp).Row - 1
'Start column (G) = first column 1
sc = 7
'End column (L) = last column - 1
ec = 12

'Do all rows of data
For i = 1 To er

'If first Col is blank, fill
If Cells(r, sc - 1) = quot;quot; Then
Set src = Range(Cells(r, sc), Cells(r, ec))
Set dest = Range(Cells(r, sc - 1), Cells(r, ec))
src.AutoFill Destination:=dest, Type:=xlFillSeries
End If
'If last Col is blank, fill
If Cells(r, ec 1) = quot;quot; Then
Set src = Range(Cells(r, sc), Cells(r, ec))
Set dest = Range(Cells(r, sc), Cells(r, ec 1))
src.AutoFill Destination:=dest, Type:=xlFillSeries
End If
r = r 1
Next i

End SubI hope someone is able to tackle this for me!

Many thanks for your help,
Steve M--
smurray444
------------------------------------------------------------------------
smurray444's Profile: www.excelforum.com/member.php...oamp;userid=28956
View this thread: www.excelforum.com/showthread...hreadid=506706Steve,

Post your messages ONCE, to ONE group. You are missing out on replies, and just complicating things
in general.

Bernie
MS Excel MVPquot;smurray444quot; gt; wrote in message
...
gt;
gt; Dear all,
gt;
gt; Someone has designed a macro for me which should perform a linear
gt; extrapolation on gaps in my dataset.
gt;
gt; However, it appears to work across the rows as opposed to down the
gt; columns. I require it to work on columns F-I and R-U (inclusive) as
gt; opposed to the whole dataset.
gt;
gt; Would anybody be able to correct the macro below to achieve this?
gt;
gt;
gt; Sub Pfil()
gt;
gt; Dim i As Long
gt; Dim r As Long
gt; Dim er As Long
gt; Dim sc As Long
gt; Dim ec As Long
gt; Dim src As Range
gt; Dim dest As Range
gt;
gt; 'Start Row
gt; r = 2
gt; 'Last row
gt; er = Range(quot;a65536quot;).End(xlUp).Row - 1
gt; 'Start column (G) = first column 1
gt; sc = 7
gt; 'End column (L) = last column - 1
gt; ec = 12
gt;
gt; 'Do all rows of data
gt; For i = 1 To er
gt;
gt; 'If first Col is blank, fill
gt; If Cells(r, sc - 1) = quot;quot; Then
gt; Set src = Range(Cells(r, sc), Cells(r, ec))
gt; Set dest = Range(Cells(r, sc - 1), Cells(r, ec))
gt; src.AutoFill Destination:=dest, Type:=xlFillSeries
gt; End If
gt; 'If last Col is blank, fill
gt; If Cells(r, ec 1) = quot;quot; Then
gt; Set src = Range(Cells(r, sc), Cells(r, ec))
gt; Set dest = Range(Cells(r, sc), Cells(r, ec 1))
gt; src.AutoFill Destination:=dest, Type:=xlFillSeries
gt; End If
gt; r = r 1
gt; Next i
gt;
gt; End Sub
gt;
gt;
gt; I hope someone is able to tackle this for me!
gt;
gt; Many thanks for your help,
gt; Steve M
gt;
gt;
gt; --
gt; smurray444
gt; ------------------------------------------------------------------------
gt; smurray444's Profile: www.excelforum.com/member.php...oamp;userid=28956
gt; View this thread: www.excelforum.com/showthread...hreadid=506706
gt;

Ok - appologies about that.--
smurray444
------------------------------------------------------------------------
smurray444's Profile: www.excelforum.com/member.php...oamp;userid=28956
View this thread: www.excelforum.com/showthread...hreadid=506706

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()