0

I'm trying to make a section of a small macro in Excel that copies info from some inputs between cells AE13 and AI13. The thing is that I want to make it so that the next row is selected by Excel once the program does its thing (so, once the program copies the content for AE13:AI13 and does some processing, it'll jump to copy the contents of AE14:AE14 and so on as long as it encounters data (for this example, let that be until the variable I'm using reaches 20)). For this I'm doing the following:

Do while Active < 20
Active = 13
'The code that does the cleanup from the prior run goes here
Range("AE" & Active & ":AI" & Active).Select
Selection.Copy
'Then here goes the rest code that does the actual program, which has been running fine prior to implementing this "Active" variable (which is not used anywhere else in the code).
Active = Active + 1
Loop

To me that's how it's supposed to go, but when I try to run this, Excel selects rows AE:AI, it activates all the cells in those columns instead of the ones in the row I'm specifying.

Could anyone help me see if I'm doing something wrong?

Kudos from a ramdon, troubled gen z trying to survive in the workplace.

Luis
  • 1
  • 2
    One note, currently you are setting `Active = 13` inside the loop so Active is basically always going to be 13 when each loops starts. Move it above the `Do While` line. I'm not sure what the rest of your code does but if it does not modify your Active variable you will be in the loop forever. – Daniel Aug 17 '22 at 00:57
  • The code that's posted only selects `AE13:AI13` in a continuous loop - as @Daniel pointed out. Something else that's not posted must be causing it to select the whole column. Obligatory link to post about selecting: [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Darren Bartrup-Cook Aug 17 '22 at 07:45

0 Answers0