dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] Copy values from a range to another range without looping

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,117

    Resolved [RESOLVED] Copy values from a range to another range without looping

    I'd like to copy the values from E3 to the last row in column 'E' to an indeterminate number of columns starting at column 'H". For example I might want to copy E3:E8 to H3:Z8 without looping. The result should be that every column from H' to Z' should have the same values as column 'E'

  2. #2

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,620

    Re: [RESOLVED] Copy values from a range to another range without looping

    in case it is useful at sometime here is a solution to the original question

    Code:
    cols = 7 '  # of columns
    lastrow = Cells(Rows.Count, 5).End(xlUp).Row
    Range("h3").Resize(lastrow - 2, cols).Value = Range("e3").Resize(lastrow - 2).Value
    tested appears to work correctly
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width