INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Autofill issue

Autofill issue

(OP)
Hi People,

I am trying to auto fill (Drag down) a row of formula's on one tab to a specific row number which is located in Cell (O7) from sheet 'RR S&C'.

This is what I have so far, but an error keeps coming up on the highlighted text in yellow. Can anyone show me where I'm going wrong please?



Sub Variants()


Application.ScreenUpdating = False

'---------------------------------------------------

Sheets("RR S&C").Range("O7").Copy
Range("O8").Select
Range("O8").PasteSpecial xlPasteValues

Sheets("RR PL").Select
Range("L7").Copy
Range("L8").Select
Range("L8").PasteSpecial xlPasteValues

Sheets("Validation").Select
Range("M7").Copy
Range("M8").Select
Range("M8").PasteSpecial xlPasteValues

' ----------------------------------------------------

Sheets("RR S&C").Select
Range("O8").Select
Value = Range("O8")
Range("A2").AutoFill Destination:=Range("A2:L" & MyValue), Type:=xlFillSeries


'----------------------------------------------------------------------------------

Application.ScreenUpdating = True

End Sub


Thanks in advance!

RE: Autofill issue

Hi,

Where have you assigned a value to MyValue?

BTW, you also have a variable named Value. That's a NO NO!!! Value is a reserve word!

Every VBA user ought to have this option checked...

Tools > Options > Eidtor -- Requite variable declaration

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Autofill issue

Okay, I'm guessing that the ending row values is what you intended to assign to MyValue...

CODE

Sub Variants()
'
    Dim MyValue
'
    Application.ScreenUpdating = False
    
    '---------------------------------------------------
    
    With Sheets("RR S&C")
        .Range("O7").Copy
        .Range("O8").PasteSpecial xlPasteValues
    End With
    
    With Sheets("RR PL")
        .Range("L7").Copy
        .Range("L8").PasteSpecial xlPasteValues
    End With
    
    With Sheets("Validation")
        .Range("M7").Copy
        .Range("M8").PasteSpecial xlPasteValues
    End With
    
    ' ----------------------------------------------------
    
    With Sheets("RR S&C")
    '
        MyValue = .Range("O8")
    '
        .Range("A2").AutoFill _
            Destination:=.Range("A2:L" & MyValue), Type:=xlFillSeries
    End With
    
    '----------------------------------------------------------------------------------
    
    Application.ScreenUpdating = True
    
End Sub 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Autofill issue

(OP)
Skip,

Thanks for looking at this. There is an error with the final part: 'Destination:=.Range("A2:L" & MyValue), Type:=xlFillSeries'.

Perhaps I should write it so that it just does it column by column?

Regards!

RE: Autofill issue

Have you tested contents of MyValue or, better, string "A2:L" & MyValue ?

combo

RE: Autofill issue

(OP)
Thanks for your help guys, all sorted now.

RE: Autofill issue

Andy,
It is customary to click on Great Post link in the post that was most helpful.
This way you say:"Thank you" to the person who helped you, but also that little star indicates to other people which post to pay attention to.

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close