excelguy
excelguy

Reputation: 1624

VBA, Autofill filling series instead of copying cells

I am trying to use Autofill to Copy Cells down, It works fine for String type records, but numeric numers it is filling the series.

Before the code runs:

enter image description here

After the code runs:

enter image description here

I want it to fill down 0's.

Here is my code:

sh.Range("G" & lastR1, PreviousColumn & lastR1).AutoFill _
   Destination:=sh.Range("G" & lastR1, PreviousColumn & lastR)

Upvotes: 0

Views: 274

Answers (2)

cadvena
cadvena

Reputation: 1093

To fill down zeros, simply set the value to zero instead of using Autofill. Use a single line of code, [a2:a5] = [a1].value for example, to set a range of cells all to the same value.

Upvotes: 1

BigBen
BigBen

Reputation: 50008

Use value transfer:

With sh
   .Range("G" & lastR1, PreviousColumn & lastR).Value = _
   .Range("G" & lastR1, PreviousColumn & lastR1).Value
End With

Upvotes: 1

Related Questions