SOLVED

VBA copy Value getting range from a specific cell

Copper Contributor

Hello,

 

I am trying to figure out how to copy value information from 1 cell to another sheet.

I.E Get a range from a cell (cell B2) in sheet A. Then copy data from cell K5 in sheet A to sheet B using the range specified in cell B2 of sheet A.

 

Thank you for any help !

2 Replies

@Jonathan865 

If you’re looking to ask a question or start a conversation about Excel, you’re in the right place!

Ask away.

Please include the following info to help others answer your question.

Welcome to your Excel discussion space!

 

Thank you for your understanding and patience

 

NikolinoDE

I know I don't know anything (Socrates)

best response confirmed by Jonathan865 (Copper Contributor)
Solution
Your request lacks some detail, but I created something based on what I think you wanted. You could modify the code to what you had in mind.

1. This code grabs the range that is entered into cell B2 of sheet A into the variable "GetRng".
2. Puts the value of cell K5, sheet A, into the range variable from step 1 on sheet B.

Sub GetValue()
Dim GetRng As Range
'set the variable to what has been entered into cell B2 of sheet A.
Set GetRng = Sheets("A").Range("B2")
'Gets the value from cell K5 in sheet A and puts it into whatever _
'cell(range) of sheet B that has been entered into cell B2 of sheet A.

Sheets("B").Range(GetRng) = Sheets("A").Range("K5")
End Sub
1 best response

Accepted Solutions
best response confirmed by Jonathan865 (Copper Contributor)
Solution
Your request lacks some detail, but I created something based on what I think you wanted. You could modify the code to what you had in mind.

1. This code grabs the range that is entered into cell B2 of sheet A into the variable "GetRng".
2. Puts the value of cell K5, sheet A, into the range variable from step 1 on sheet B.

Sub GetValue()
Dim GetRng As Range
'set the variable to what has been entered into cell B2 of sheet A.
Set GetRng = Sheets("A").Range("B2")
'Gets the value from cell K5 in sheet A and puts it into whatever _
'cell(range) of sheet B that has been entered into cell B2 of sheet A.

Sheets("B").Range(GetRng) = Sheets("A").Range("K5")
End Sub

View solution in original post