Autocopy instead of autofill

  • Thread starter Thread starter Basta1980
  • Start date Start date
B

Basta1980

Hi all,

I use this code to autofill a range.

Private Sub CommandButton1_Click()
'Macro_om_datum_te_genereren
Dim rng As Range
Set rng = ActiveSheet.Range("J9")

rng.AutoFill Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1))

End Sub

Things is, don't want VBA to fill but to copy the information. What small
modifcation needs to be done to get this code working?!

Regards

Sebastiaan
 
from
rng.AutoFill Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1))

to

rng.copy destination:=Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1))
 
..autofill has several parms that you can include.

I'd try:

rng.AutoFill _
destination:=Range(rng, rng.Offset(0, -1).End(xlDown).Offset(0, 1)), _
type:=xlFillCopy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top