Copying Cell address to another Cell

Dean001

New Member
Joined
Sep 2, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Had loads of help so far and hopefully this is the last for a while...
I am copying values from one sheet to another, this cannot be automated as it is essentially random and carried out visually, but the bit I cant get to work is I also need to copy the cell address of the values I have copied. They need to be displayed in adjacent cells, rather than just using the Paste link option.
ie. the value needs to be copied to column D and the cell address needs to be copied to column C. I am using the below macro to copy the values (the best I have managed so far is to use the paste link function:

Selection.Copy
Sheets("DATA Dump").Select
Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste Link:=True
Sheets("data1").Select
Application.CutCopyMode = False
End Sub

Any help would be grately appreciated.
Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Do you need the cells to be linked? If all your doing is copying the values from one sheet to another, it would be far quicker and easier to just assign the values to the destination cell(s) and avoid using the clipboard altogether. So, generally,

VBA Code:
Sheets("Destination").Cells(1, 1).Value = Sheet("Source").Cells(1, 1).Value

Will instantly transfer the value in Cell A1 in the Worksheet "Source" to the corresponding Cell A1 in Worksheet Destination.

I don't know what the Selection you're copying in the above code snippet is, but I suppose your code could be written:

VBA Code:
Sheets("DATA Dump").Cells(Rows.Count, "D").End(xlUp).Offset(1).Value = Selection.value

To put the address in the column to it's left (Column C), you could add:

VBA Code:
Sheets("DATA Dump").Cells(Rows.Count, "D").End(xlUp).Offset(1, -1).Value = Selection.Address

Does that help?
 
Upvote 0
How about
VBA Code:
   Dim Rng As Range
   
   Set Rng = Selection
   With Sheets("DATA Dump").Range("D" & Rows.Count).End(xlUp).Offset(1)
      .Value = Rng.Value
      .Offset(, -1).Value = Rng.Address
   End With
 
Upvote 0
Solution
Do you need the cells to be linked? If all your doing is copying the values from one sheet to another, it would be far quicker and easier to just assign the values to the destination cell(s) and avoid using the clipboard altogether. So, generally,

VBA Code:
Sheets("Destination").Cells(1, 1).Value = Sheet("Source").Cells(1, 1).Value

Will instantly transfer the value in Cell A1 in the Worksheet "Source" to the corresponding Cell A1 in Worksheet Destination.

I don't know what the Selection you're copying in the above code snippet is, but I suppose your code could be written:

VBA Code:
Sheets("DATA Dump").Cells(Rows.Count, "D").End(xlUp).Offset(1).Value = Selection.value

To put the address in the column to it's left (Column C), you could add:

VBA Code:
Sheets("DATA Dump").Cells(Rows.Count, "D").End(xlUp).Offset(1, -1).Value = Selection.Address

Does that help?

Hi,

I dont need the cells to be linked, that was just the best I could do.
Where exactly would I add the above code?
would it need to look like this:

Selection.Copy
Sheets("DATA Dump").Select
Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).Select
Sheets("DATA Dump").Cells(Rows.Count, "D").End(xlUp).Offset(1, -1).Value = Selection.Address
ActiveSheet.Paste Link:=True
Sheets("data1").Select
Application.CutCopyMode = False
End Sub

Thanks
 
Upvote 0
How about
VBA Code:
   Dim Rng As Range
  
   Set Rng = Selection
   With Sheets("DATA Dump").Range("D" & Rows.Count).End(xlUp).Offset(1)
      .Value = Rng.Value
      .Offset(, -1).Value = Rng.Address
   End With
Hi,

Would that be a total replacement of the code or would I need to add it in?

Thanks
 
Upvote 0
That replaces everything you posted.
 
Upvote 0
I think I needed to be more specific as to where the address comes from, it needs to be from the original copy, so the $$ address in the image below
 

Attachments

  • cell address.PNG
    cell address.PNG
    12 KB · Views: 2
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top