copy in to next coulmn and freeze orignal coulm

kasbac

Active Member
Joined
Jan 2, 2008
Messages
344
Hi There

Would anyone be able to help me with a macro that copy/pastes the formulas found in the range D41:D63 in to E41:E63 and then convert the results in D41:D63 in to values.

The next time I run the macro it should take the range E41:E63, copy paste the formulas in to coulmn F41:F63 and then convert the results in E41:E63 in to values.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try

Code:
Sub atest()
Dim LC As Long
LC = Cells(41, Columns.Count).End(xlToLeft).Column
With Range(Cells(41, LC), Cells(63, LC))
    .Copy Destination:=Cells(41, LC + 1)
    .Value = .Value
End With
End Sub
 
Upvote 0
hmm nothing seemed to happen when i ran the macro?

Please note that I have formulas/values in all cells in the range B40:L63
 
Upvote 0
It should have copied the last column to the last column + 1.

If that isn't what you want, how does the macro determine which column to copy?
 
Upvote 0
The starting point should be coulmn D, from there on everytime time i run the macro the starting point should move one coulmn to the right, is this possible?

If not the only option that I see is if the macro can look in to the formulas in the cells. The starting coulmn will always have "=$D$27" in line 41??
 
Upvote 0
Try

Code:
Sub atest()
Dim LC As Long, Found As Range
Set Found = Rows(41).Find(what:="=$D$27", LookIn:=xlFormulas, lookat:=xlWhole)
If Found Is Nothing Then
    MsgBox "Formula not found"
    Exit Sub
End If
LC = Found.Column
With Range(Cells(41, LC), Cells(63, LC))
    .Copy Destination:=Cells(41, LC + 1)
    .Value = .Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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