Help with a dynamic macro needed

kasbac

Active Member
Joined
Jan 2, 2008
Messages
344
Hi there

I have an issue with a macro that I’m hoping for some help with.

The first step is pretty simple I would like for the macro to firstly copy the formula found in the range A1:A5 to B1:B5. Then I would like to copy/paste the values of range A1:A5 to A1:A5.

The trick is now that the next time I run the macro I want the macro to copy the formulas in the range B1:B5 to C1:C5 and then paste the values of range B1:B5 to B1:B5. Third time should it should then copy column C to D and so forth.

Hope someone will be able to help me out.

As always any help is very much appreciated
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Assuming that columns B onwards are initially empty try

Code:
Sub test()
Dim LC As Integer
LC = Cells(1, Columns.Count).End(xlToLeft).Column
With Range(Cells(1, LC), Cells(5, LC))
    .Copy Destination:=Cells(1, LC + 1)
    .Value = .Value
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0
Can we assume the column progression is based on the next free column available?

Try:

Code:
Sub copyNext()
    newcol = Cells(1, Columns.Count).End(xlToLeft).Column
    With Cells(1, newcol).Resize(5, 1)
        Cells(1, newcol + 1).Resize(5, 1).Formula = .Formula
        .Value = .Value
    End With
End Sub

It might be useful to see an example of the formulas to be copied, in case the cell refs are relative rather than absolute ($ signs)
 
Upvote 0
Hi Guys

First of all thank you for you input. ExcelR8R im going to use you solution as this seems to copy the formulas as I want it to. I do however have a sligt issue. The cells that I refeered to was only meant as an example. I had hoped that I would have been able to modify the macro in order to adapt it to my real life data however I must ask for some help with this.

My real life data starts in cell C5:C10, how should the macro be changed to take this in to account?? further more i have headings above the coloumns that I want to paste in the new values to, does this make difference to the macro??

Hope one of you will be able to help me out
 
Upvote 0
Here is my real life setup:
PMP Template.xls
ABCDEFG
1
2MonthJan
3Week2345
4Numberofopenseats285
5NumberofopenHours83.491
6Numberofopenseatswith0Hoursperweek77
7Averageopendays57
8Numbersofseatswithoverduestartdate98
9Numberofseatswithoverdueenddate56
Overview
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,304
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top