[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

VBA maco

Hello,

I need build simple macro for my excel file.
I want to repeat A1:F10 to the end of the sheet XEY1:XFD10



please help
h.
Book1.xlsx
0
henryk123
Asked:
henryk123
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Patrick MatthewsCommented:
That worksheet has 16,384 columns.

16,384 is not evenly divisible by 6.
0
 
henryk123Author Commented:
copy and paste next 100 times
0
 
etech0Commented:
Try this. It'll take a while to run, though.


Sub copy()
'
' copy Macro
'

For x = 1 To 3000
    
    Range("A1:F10").copy
    Cells(1, x * 6 - 1).Select
    ActiveSheet.Paste
Next
End Sub

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kgerbChief EngineerCommented:
I think this will do what you want.
Sub CopyA10F10()
Range("A10:F10").Copy Range("G10", Cells(10, 6 * Int((Columns.Count) / 6)))
End Sub

Open in new window

Kyle
0
 
etech0Commented:
you may have to adjust the 3000 to whatever number x it's up to when it errors at the end of the worksheet. click debug, hover over the x to see its value, and change 3000 to one less than that.
0
 
kgerbChief EngineerCommented:
Here is a more generalized version.  Simply input the starting cell and ending cell of the range you want to copy.  It will then copy the whole range as many times as it can before it runs out of columns.
Sub CopyToLastCol()
Dim FCell As Range, LCell As Range, cols As Long
Set FCell = Range("A10")
Set LCell = Range("F10")
cols = LCell.Column - FCell.Column + 1
With Range(FCell, LCell)
    .Copy Range(Cells(FCell.Row, LCell.Column + 1), Cells(FCell.Row, cols * Int((Columns.Count) / cols)))
End With
End Sub

Open in new window

Kyle
0
 
henryk123Author Commented:
thx, working great
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now