ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Macro? (https://www.excelbanter.com/excel-programming/394030-simple-macro.html)

Felix

Simple Macro?
 
I would like to create a simple macro that

-starts at a cell of my choosing
-copies the formula there
-moves 12 columns across to the right and pastes that formula there
-copies the formula there
-moves 1 column across to the right and pastes that formula again
-copies the formula there
-moves 1 column across to the right and pastes that formula again

I tried to record something, but I cannot make it move across the same row...

steve_doc

Simple Macro?
 
Using Range.Offset(0,12) < moves 12 columns to you right

the above is out of context, and will probably not work if copied and
inserted into your macro

as eg you would be better of coding something like the following
'Pseudo Code
'Activate cell to copy
Worksheet.Range("YourCell").Activate
ActiveCell.copy
ActiveCell.offset(0,12).Paste

Personally I prefer to use
Dim rg as Range
Set rg = ThisWorkbook.WorkSheets(1).Range("YourCell")

With rg
..Copy
..Offset(0,12).Paste
..Offset(0,13).Paste
..OffSet(0,14).Paste
End With

HTH

"Felix" wrote:

I would like to create a simple macro that

-starts at a cell of my choosing
-copies the formula there
-moves 12 columns across to the right and pastes that formula there
-copies the formula there
-moves 1 column across to the right and pastes that formula again
-copies the formula there
-moves 1 column across to the right and pastes that formula again

I tried to record something, but I cannot make it move across the same row...



All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com