Solved

Excel Copy formulas from one column to another column

Posted on 2013-05-24
7
327 Views
Last Modified: 2013-06-05
Hi, I want to copy the contents from Column X1 to X2, X3,X4 till the end of my last column. X1 starts in column F696 and it goes down to F1356. The last column is YJ. There are two empty columns between each X. Can this be down with a macro, a loop, or code?
conernesto.

X1      b      b      X2      b      b      X3      b      b      X4
100                  100                  100                  100
200                  200                  200                  200
300                  300                  300                  300
0
Comment
Question by:Conernesto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39195329
The two columns between: are they empty or is there any data in there?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39195339
If there is NO data in the blank columns then you would not need a macro

Select the range F696:H1356          (3 columns)
Now at the bottom left corner of the selection there is a tiny black square.
Drag this black square as far right as necessary.
0
 
LVL 81

Expert Comment

by:byundt
ID: 39195716
It's much faster to copy values. Here's a macro to copy formulas, however:
Sub CopyX()
Dim i As Long, Start As Long, Finish As Long
Dim rg As Range
Application.ScreenUpdating = False
Start = Columns("F").Column
Finish = Columns("YJ").Column - Start
Set rg = Range("F696:F1356")
For i = 3 To Finish Step 3
    rg.Copy
    rg.Offset(0, i).PasteSpecial xlPasteFormulas
Next
End Sub

Open in new window

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39196161
If all the formulas down column F are the same then I believe, although not tested that way, that this would be quicker than copying

Sub cpyColsWgaps()
    Dim i As Integer
    Dim trng As Range
    Set trng = Range("F696:F1356").Offset(, 3)
    For i = 6 To Range("YJ1").Column - 6 Step 3
        Set trng = Union(trng, Range("F696:F1356").Offset(, i))
    Next i
    trng.FormulaR1C1 = Range("F696").FormulaR1C1
End Sub
0
 

Author Closing Comment

by:Conernesto
ID: 39223491
Both solutions worked fine. I like the second solution because it also copies the formats.

conernesto.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39223780
You have selected a comment which is not a solution. Can you specify the serial number of the solution which is working for you?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question