+ Reply to Thread
Results 1 to 3 of 3

Macro: cell value from Sheet1 as cell reference on Sheet2 in which to paste

  1. #1
    Registered User
    Join Date
    07-09-2023
    Location
    Malaga, Spain
    MS-Off Ver
    365
    Posts
    2

    Macro: cell value from Sheet1 as cell reference on Sheet2 in which to paste

    Hi, I have a cell on Sheet1 that has the cell reference from a MATCH function that tells me the cell reference on Sheet2 in which I wish to paste a value.

    The ACTUAL value I wish to paste into my destination cell in Sheet2 is the contents of cell C8 from Sheet1, which is a date.
    The Cell Reference in Sheet2 in which I wish to paste that value is calculated with a MATCH function and shown in cell M2 of Sheet1 (which for instance might be "E21").
    So I want to pick up the copied value from C8 and paste that value in the cell reference in Sheet2 as dictated by the value of M2 on Sheet1.

    My code so far below picks up C8 and copies it into fixed cell reference E2 of Sheet2, but I want that "E2" Range to be a variable row number within column E as defined by the cell reference held in cell M2 of Sheet1 (e.g. "E21").
    How do I do that? (the code below is the result of recording the macro, hence the fixed "E2" destination cell range)

    Sheets("Sheet1").Select
    Range("C8").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Selection.Font.Bold = False
    Selection.NumberFormat = "dd/mm/yyyy"
    Last edited by AndyHughson; 07-09-2023 at 04:01 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: Macro: cell value from Sheet1 as cell reference on Sheet2 in which to paste

    Hi Andy,

    It would be helpful if you attach a sample workbook (see yellow banner at top). This makes it much easier to see what data you are working with and testing solutions offered.

    Anyway, I made some assumptions. Refer to the attached file and let us know if that works for you.

    Regards



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ORoos; 07-10-2023 at 09:28 AM.
    If your Question is answered; please mark it SOLVED. If you are happy with a member's solution, say 'Thanks' and click the 'Star' to Add Reputation.

  3. #3
    Registered User
    Join Date
    07-09-2023
    Location
    Malaga, Spain
    MS-Off Ver
    365
    Posts
    2

    Re: Macro: cell value from Sheet1 as cell reference on Sheet2 in which to paste

    Great - that worked a treat, thanks!

+ 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. Replies: 1
    Last Post: 01-31-2020, 11:29 AM
  2. [SOLVED] Copy cell from sheet2 and paste it back on same row of sheet1.
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2013, 12:32 PM
  3. [SOLVED] Reference sheet2 by cell address in sheet1
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 05:29 AM
  4. [SOLVED] copy paste value from sheet1 to sheet2 in empty cell only
    By koi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2013, 03:46 AM
  5. Replies: 0
    Last Post: 11-15-2012, 09:51 AM
  6. [SOLVED] Need a macro to Copy Cell in Sheet1 to the next empty cell in Column A, Sheet2
    By killerthun in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-16-2012, 01:21 PM
  7. Macro to copy range of cell from sheet1 to sheet2 based on a cell value in sheet2
    By drgwhizz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-25-2012, 10:39 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