+ Reply to Thread
Results 1 to 6 of 6

VBA Copy Cells Referenced in Workbook

Hybrid View

  1. #1
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,107

    VBA Copy Cells Referenced in Workbook

    Hi All

    I need a VBA to copy cell referenced in cell B1 to cell referenced in cell B2 as per workbook attached.

    Thank you.
    Joseph
    Attached Files Attached Files

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,391

    Re: VBA Copy Cells Referenced in Workbook

    Potentially would not need copy, the below would be faster if using a lot:

    Range("F3").Value = Range("E1").Value
    Or are you after taking the range references from the worksheet?
    If things don't change they stay the same

  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,107

    Re: VBA Copy Cells Referenced in Workbook

    Thank you CheeseSandwich! Sorry, I forgot to mention.. cells referenced in cells B1 and B2 are subject to change.

  4. #4
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,391

    Re: VBA Copy Cells Referenced in Workbook

    lol was that a trick, you highlighted J3 but I3 was the destination cell

    try:
    Sub CopyCell()
        Dim fRng As Range, tRng As Range
        
        Set fRng = Range(Range("B1").Value)
        Set tRng = Range(Range("B2").Value)
        tRng = fRng
    End Sub

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,107

    Re: VBA Copy Cells Referenced in Workbook

    Thanks CheeseSandwich! Works like a charm! And, I have managed to shorten it to:
    Range(Range("B2").Value) = Range(Range("B1").Value)
    Here's a Rep for you!

  6. #6
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,391

    Re: VBA Copy Cells Referenced in Workbook

    Quote Originally Posted by josephteh View Post
    Thanks CheeseSandwich! Works like a charm! And, I have managed to shorten it to:
    Range(Range("B2").Value) = Range(Range("B1").Value)
    Here's a Rep for you!
    Thanks for the Rep,

    It is shorter but shorter is not always better - I like to define everything as I find it easier to read later on - it's an each to their own thing...

    Happy to help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Linking referenced cells to different workbook
    By mrsak87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2019, 06:39 AM
  2. Replies: 2
    Last Post: 02-20-2017, 12:48 PM
  3. Macro Help to Save Workbook w/ Name Referenced in Cell of Same Workbook
    By Warne57032 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2016, 11:13 AM
  4. [SOLVED] Macro to copy files referenced in hyperlinked cells to another folder
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-12-2014, 02:36 AM
  5. [SOLVED] Copy range to new workbook w/some cells as values & some cells as formulas in new workbook
    By happydayze in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2013, 12:42 PM
  6. Change a row of cells referenced workbook
    By rkemmerich in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-09-2013, 12:50 PM
  7. Sorting Referenced Cells in VBA and Keeping Them Referenced
    By BrownTeddyBear in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2009, 06:15 AM

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