+ Reply to Thread
Results 1 to 7 of 7

[SOLVED] Fill across and down

Hybrid View

b50 [SOLVED] Fill across and down 10-04-2010, 11:45 AM
StephenR Re: Fill across and down 10-04-2010, 12:17 PM
b50 Re: Fill across and down 10-04-2010, 12:27 PM
StephenR Re: Fill across and down 10-04-2010, 12:31 PM
b50 Re: Fill across and down 10-04-2010, 12:40 PM
StephenR Re: Fill across and down 10-04-2010, 02:17 PM
b50 Re: Fill across and down 10-04-2010, 03:18 PM
  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    54

    [SOLVED] Fill across and down

    Hello,

    See attached spreadsheet for example.

    I can copy all of the data in D3 down for all for all cells that have data in column C with the following code:

    
        Range("D3").Select
        Selection.AutoFill Destination:=Range("D2:D" & Range("C65536").End(xlUp).Row)
    However, my problem is that I can't figure out how to copy it across to the cells. I need it to look at row 2 and if it has data then input the formula in the respective row 3 and fill it down based on column c.

    Let me know if that doesn't make sense.

    Thank you for anyone who can help.


    example.xls
    Last edited by b50; 10-04-2010 at 03:18 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Fill across and down

    Not sure I understand, don't you mean D2, not D3? However, try this:
    Sub x()
    
    Dim c As Long
    
    For c = 4 To Cells(2, Columns.Count).End(xlToLeft).Column
        Cells(2, c).AutoFill Destination:=Range(Cells(2, c), Cells(Cells(Rows.Count, "C").End(xlUp).Row, c))
    Next c
    
    End Sub

  3. #3
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    54

    Re: Fill across and down

    That works great except that I have a vlookup formula in column D3. I guess I forgot to put that in my example. So, there is a formula there, that I need to do exactly what your code does above, but with the vlookup that is in column d.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Fill across and down

    Now you've lost me. Update your workbook?

  5. #5
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    54

    Re: Fill across and down

    Ok, the formula that i have in the spreadsheet doesn't work, but thats not a big deal. I have it working in my main sheet.

    The vlookup formula that is in D3 needs to be filled down based on column b. It then needs to be filled over based on row 2, similar to what your first code did, but with the vlookup that is in D3.


    Thank you, sorry for the confusion.

    example2.xls

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Fill across and down

    If you're just trying to copy a formula from D3, perhaps this?
    Range("D3").Copy Range("D3").Resize(Cells(Rows.Count, "B").End(xlUp).Row - 2, Cells(2, Columns.Count).End(xlToLeft).Column - 3)

  7. #7
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    54

    Re: Fill across and down

    works perfectly. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1