Forum Discussion
Jonathan865
Sep 20, 2021Copper Contributor
VBA copy Value getting range from a specific cell
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 u...
- Sep 20, 2021Your 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
SWalter2937
Sep 20, 2021Brass Contributor
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. 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