Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 25 of 25

Thread: UsedRange, copy paste values?

  1. #21
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    It goes in your source worksheet, its purely to give you an up to date usedrange reference by giving the new usedrange the same name each time
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  2. #22
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    It seems I looked at the wrong code when I made my last comment oops
    Personally I don't think thats necessary, but whatever works. Far be it for me to call anything overkill

  3. #23
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Lol! Matt i was just trying to facillitate him having a named range to call on (easier than UsedRange) where that named range is always updated everytime the source sheet s updated....i thought that it may be easer to use in his coding!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #24
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Makes sense.. though using Wss.UsedRange in place of Wss.Range("MyRange") would prevent the code from running all the time I can see a use for it if you wanted to have a named range based on the used cells of a specific column, could be quite useful with formulas referencing a column (though dynamic formulae would work just as well, and without VBA)

    Taking your idea one step further, you could do the same for all sheets in a workbook by placing the following in the ThisWorkbook module:[vba]Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim Ur As String
    Ur = Sh.UsedRange.Address
    Sh.Range(Ur).Name = "MyRange"
    End Sub[/vba]

  5. #25
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    of course!, you then only have to know the sheet name you're working with as the named range will be the same for all sheets.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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