Solved

Excel Copy formulas from one column to another column

Posted on 2013-05-24
7
283 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
  • 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 80

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now