• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

MACRO - Paste to a referenced cell

FlipRA

New Member
I need to paste a value obtained from an earlier run macro into a specific cell, the location of which is specified by a user input (cell A1 in my example).


Let's say the user has input 5 into cell A1.

Based on the A1 value of 5, the CHOOSE command has selected the fifth entry in a row B, let's say the value in B5 is 50.

Macro1 now runs that gyrates and determines that the value should really be 27, not 50.

I now need to paste 27 into B5.


Had the user input say 4, into A1, then the paste command needs to paste the resulting answer into B4.


Thanks, FlipRA
 
Hi


The VBA code could be as follows:


Assuming that xx = the user input in A1 and Answer is the result that you want to copy


Dim xx as integer


Range("B" & xx) = Answer


cheers


kanti
 
Thanks, kanti, I think you we are about there, but, A1 can (will) change depending on what the user inputs into cell A1. I can't hard wire the value into my macro.


I don't know what xx is. It can be any integer from 1 to 10, for simplicity, and is a user input.


I need to "call up" the value the user input into A1, and use that value to reference the correct cell to paste Answer.


A1 = 5 (user input)

B1 to B10 are "temporary answers"

Macro1 runs to determine that B5 should be 27, the Answer, and stores it in C1

C1 = Answer


If there is a way to use offset, along the lines of


Range("B1").Select

Selection.Offset(0. A1)


FlipRA
 
FlipRa,


The xx that i indicated is the value in A1, so if A1 is 5, Cell B5 will change, if A1 is 15 cell B15 will change. So this code is correct. In VBA you are building up the range to be B + whatever is in A1


xx = Range("A1")

Range("B" & xx) = Answer


kanti
 
Back
Top