How to generate a report from a recorded macro?

Asked

Viewed 58 times

0

Good afternoon to you all, I recorded a macro to generate a report from a spreadsheet that I am feeding with data. Basically the macro will create another workbook in the same worksheet and paste the data vertically (transpose). However, I need to go back to the original spreadsheet and copy another table, then when returning the new worksheet created the macro gives error because of the name of the created worksheet.

ActiveWindow.SmallScroll Down:=-21
Sheets("MUNICÍPIO").Select
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24
Range("AK5:AN24").Select
Selection.Copy
Sheets("Planilha15").Select

The macro gives an error on this last line, because the file will not select "Spreadsheet 15" again. I would like to resolve this by fixing the name of the spreadsheet to Report, or even any name, just to avoid this error.

Thank you.

1 answer

2


Application.Workbooks("<nome da sua pasta de trabalho com extensão>").Activate

You can also delete this, is the recording of the mouse scroll.

ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24

Browser other questions tagged

You are not signed in. Login or sign up in order to post.