• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Excel macro question

MrBond

Diamond Member
I'm trying to get an excel macro written to make some calculations easier. Here's the situation.

I've got two columns of data, call them A and B. I have a rather elaborate calculation setup in the spreadsheet that relies on two numbers in Cells D1 and E1. This calculation can't be combined into one cell in any way (trust me, I've tried). The calculation spits out the result into Cell G1.

What I want to do is write a macro that copies the values from A1 and B1 into D1 and E1, then copies the value of the result from G1 into cell C1. When this is all done, I want it to move to the next empty cell in columns A and B and loop until it's at the end of the data.

I've got everything written except something to copy the values in A1 and B1 together. Anyone know the code I need to use?
 
What do you mean by "copy the values in A1 and B1 together?" If you mean copying both together and then pasting A1 into D1 and B1 into E1, then this (or something similar) will do the trick.
 
Originally posted by: mayest
What do you mean by "copy the values in A1 and B1 together?" If you mean copying both together and then pasting A1 into D1 and B1 into E1, then this (or something similar) will do the trick.
Yeah, that's what I want to do, except the range won't always be A1 and B1. It's two columns of data, once it copies A1 and B1 (and does the associated calculation/pasting), I want it to move to A2 and B2.

I may have figured out a different way to do it, I've got to run an experiment now so I'm not sure.
 
Ok, I thought you already had all of the other logic figured out. This code will go row by row and copy and paste from A:B to D:E.

KLin, your code just does the same copy and paste over and over. You forgot to switch rows.
 
Originally posted by: mayest
Ok, I thought you already had all of the other logic figured out. This code will go row by row and copy and paste from A:B to D:E.

KLin, your code just does the same copy and paste over and over. You forgot to switch rows.

I forgot to replace the 1 with the variable i 😛. You placed the i in the wrong spot though in your code.
 
Originally posted by: mayest
Ok, I thought you already had all of the other logic figured out. This code will go row by row and copy and paste from A:B to D:E.

KLin, your code just does the same copy and paste over and over. You forgot to switch rows.
Sorry for the delay in updating the thread. I got sidetracked with another project last Friday and yet another one today. I should have some time to work on this spreadsheet this afternoon and I'll give this code a try. It certainly looks like it'll work for what I need. Thanks!
 
Back
Top