Offset Property

Solved/Closed
Mithun - Dec 26, 2008 at 01:12 AM
 Mithun - Dec 26, 2008 at 01:31 AM
Hello,

I am trying to create a Macro that sizes itself up using the adjacent column and the paste it. Simply to use it for a Pivot table for example, here I am adding a column called Quarter and populating it with Q1. Any ideas would be greatly appreciated!!

Sub zxxx()
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Quarter"
ActiveCell.Offset(0, -1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Q1"
ActiveCell.Select
Selection.Copy
Range(Selection, Selection.End(xlUp)).Select
Range("Offset(1, 0)", "Select.SpecialCells(xlCellTypeLastCell)").Select
ActiveSheet.Paste
End Sub
Related:

1 response

Hi Guys, I cracked it !!

If you know a easier method - Please let me know..

Sub zxxx()
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Quarter"
ActiveCell.Offset(0, -1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Q1"
ActiveCell.Select
Selection.Copy
Range(Selection, Selection.End(xlUp).Offset(1, 0)).Select
ActiveSheet.Paste
End Sub
0