Create Macro to change a specific ( variable ) cell value to a new value found in another cell.

ricky bobby

New Member
Joined
Jun 17, 2015
Messages
4
I'm pretty new at excel macro's but this is what I'm trying to do. Any help is appreciated.

I need to create a command button macro to take a value from a fixed cell address and enter the data at another variable cell address that is entered at a fixed cell address.

ie.<o:p class="" style="box-sizing: border-box;"></o:p>
Cell K6 has the value that i need to post. The value in K6 will change upon user input at another cell. <o:p class="" style="box-sizing: border-box;"></o:p>
Cell K7 has the address of the cell where I need to post it. The address in K7 will change upon user input at another cell. An example of an address in K7 looks like this... $J$12, I could probably get it to show without the symbols if needed. (J12)<o:p class="" style="box-sizing: border-box;"></o:p>
Any thoughts?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Code:
Range(Range("K7").Value).Value = Range("K6")


Thank you Malkoti, this code works perfectly when I insert the command button on sheet2 which is where the K7 and K6 cells are. When I insert the command button on Sheet1, I get an error. I'm wondering if the "Private Sub" is the issue in this command?

Private Sub CommandButton1_Click()
Range(Range(Sheet2!"K7").Value).Value = Range(Sheet2!"K6")
End Sub

Any thoughts on this?
 
Upvote 0
When written as above it says expected separator or ). If I write is as..... Range(Range("Sheet2!K7").Value).Value = Range("Sheet2!K6"), the error code is "invalid range of method
 
Upvote 0
Use sheets object to specify sheet name:

Code:
Sheets("SheetNameHere").Range(Sheets("Sheet2").Range("K7").Value).Value = Sheets("Sheet2").Range("K6")
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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