Paste Cell Reference into current cell contents

bruderbell

Active Member
Joined
Aug 29, 2006
Messages
374
Hi, I've tried searching the board, but didn't find what I'm looking for.

What I'm trying to do is this:

I want the macro to paste the cell reference (C6, for example) of the currently highlighted cell into an already existing formula in a different cell. Basically, I want it to tag the cell reference onto the end of the current cell text of the 2nd cell. I know how to get the proper cells selected and such, and I know how to do copy-paste stuff. But there doesn't appear to be a special paste that will paste the cell reference. And even more difficult looking is the prospect of tagging this copied info onto the end of the 2nd cell.

Any help?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
not clear.

but try something like this . woes this give you some idea to go about.

Code:
Sub adding()
        Dim a, b As String
        a = Range("c1").Formula
        MsgBox a
        b = Range("C8").Address
        MsgBox b
        Range("a10").Value = a & "*" & b
                End Sub
 

bruderbell

Active Member
Joined
Aug 29, 2006
Messages
374
Thanks for the help. I'm still a little fuzzy on it. Could you tell me what each command does so that I know how to adapt it to my situation?
 

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
I suggest
enter some numbers in A1 and B1
enter some formula in C1 e.g. =a1*b1
and enter some number in C8

keep the sheet on one side and the vb editor on the other side in the same screen.
now run the macro by steps i.e. by repeatedly hitting F8
see what happens in the sheet. finally in A10
you will get a hang of the code.
I presume this is what you want.
if it is something else revert to the newsgroup
venkat
 

bruderbell

Active Member
Joined
Aug 29, 2006
Messages
374
Code:
    Dim a, b As String
    a = Range("C4").Formula
    b = Range("A1").Address
    Range("C4").Formula = a & "+" & b

I found that this works. Thanks for the help venkat. Your suggestion got me there.

-bruderbell
 

Forum statistics

Threads
1,141,923
Messages
5,709,360
Members
421,632
Latest member
BrennieB

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
Top