Thread: Autofill VBA Q
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
[email protected] seanryanie@yahoo.co.uk is offline
external usenet poster
 
Posts: 73
Default Autofill VBA Q

On Wednesday, November 16, 2016 at 3:41:11 PM UTC, Claus Busch wrote:
Hi Sean,

Am Wed, 16 Nov 2016 07:17:13 -0800 (PST) schrieb :

Can't get my head around this, with formula below, if there is only 2 rows of data (row 1 is header stuff), B2 will = 0 (its embedded with formula =IF(T30,1,B2+1), it should be 1 and B3 = 0, it should be <blank. Note there is a value in A1 & A2, hence the check on Column A

If there are more than 2 rows, formula works perfectly


I hope I understand your correctly.
Try:

Sub AutoFill()
Dim LRow As Long

With ActiveSheet
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("B2") = IIf(LRow 2, 1, 0)
If LRow 2 Then
.Range("B3:B" & LRow).Formula = _
"=IF(T30,1,B2+1)"
End If
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016


Claus, thats it, you've cracked it. Many thanks