Consulting

Results 1 to 5 of 5

Thread: Having troubles with XlFillDefault

  1. #1

    Exclamation Having troubles with XlFillDefault

    Hey guys I just started learning how to use VBA.
    Currently I'm stuck with Run Time error 1004 and it says"Application-defined or object-defined error".
    Here's the code:
    Worksheets("Data").Range("A9:C9").AutoFill Destination:=Worksheets("Data").Range(Cells(9, 1), Cells(35, 3)), Type:=xlFillDefault
    The weird thing is when I'm viewing on the "Data" Worksheets, it runs without any error.
    However, I tried to run the code when I'm viewing my other worksheet and it gave me an error.



    I tried to run another code and it can run without me being on the "Data" Worksheet. Here's the code below:
    Sheets("Data").Range("A9:C9").AutoFill Destination:=Sheets("Data").Range("A9:C35"), Type:=xlFillDefault

    Anyone knows the reason why? I'm sorry if I didn't clarify my problems clearly.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I've never tried to fill multiple columns. Nothing in any help file hints it was possible
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    The problem is that you haven't fully qualified the ranges in the destination, try
    With Worksheets("Data")
       .Range("A9:C9").AutoFill Destination:=.Range(.Cells(9, 1), .Cells(35, 3)), Type:=xlFillDefault
    End With

  4. #4
    OMG thank you so much it works!

  5. #5
    You're welcome & thanks for the feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •