Link to home
Start Free TrialLog in
Avatar of W.E.B
W.E.B

asked on

Excel 2007 code

Hello,
I'm using below code,
the problem I have is, It fills out the empty cells.on column AC.

if Column H has 5ooo orders, I need Column AC to stop at 5000,
if Column H has 7300 orders, I need Column AC to stop at 7300,
and so on

Sub Service()
    Sheets("Import_to_CC").Select
    Range("AC2").Select
    ActiveCell.FormulaR1C1 = "=IF(ISERR(FIND(""*"",RC[-21])),""249"",""250"")"
    Selection.AutoFill Destination:=Range("AC2:AC10000"), Type:=xlFillDefault
    Range("AC2:AC10000").Select
End Sub

Any help is appreciated.
.
,
Avatar of JP
JP
Flag of United States of America image

Try this

Sub Service()
    Sheets("Import_to_CC").Select
    Range("AC2").Select
    ActiveCell.FormulaR1C1 = "=IF(ISERR(FIND(""*"",RC[-21])),""249"",""250"")"
    Selection.AutoFill Destination:=Range("AC2:AC" & [H65536].end(xlup).rows), Type:=xlFillDefault
    Range("AC2:AC" & [H65536].end(xlup).rows).Select
End Sub

Open in new window

Avatar of W.E.B
W.E.B

ASKER

I get error,
debug

Selection.AutoFill Destination:=Range("AC2:AC" & [H65536].End(xlUp).Rows), Type:=xlFillDefault
ASKER CERTIFIED SOLUTION
Avatar of JP
JP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of W.E.B

ASKER

Excellent,
thank you.