Copy Formula From Left To Righ - Modify my VBA

Myproblem

Board Regular
Joined
May 24, 2010
Messages
198
Basicly I have to copy formula from left to right.
Certain ranges contains values and formulas, let say as example (even there are many similar ranges, that is way I need VBA):

Range: A2:C10Column A is totaly values, which is OK
Column B currently has only values (this is subject of my wanted VBA)
Column C has both values and formula (formulas which I need and want to copy to column B) , but problem is there is not range of values and range of formula to simply copy formula to column B.

My proposed solution is VBA which give reference to this forum basicly should do:
With selected range in Column C, copy cells with formulas and go to similar range in column C and copypaste just formulas in rows where formulas were in column C.
Like: B2:B10 contains values
C2:C4 contains formulas
C5:C7 contains values
C8:C10 contains formulas
I want to select C2:C10, copy formulas and go to B2:B10, select it and copy paste only formulas to B2:B10, but leave values in rows where it is as in Column C.

My VBA is not working, so I need your help, here is it
Sub CopyFormulaFromLeftToRighInSelecltion()
Dim cel As Object
Set SelRange = Selection
Dim Message$, Title$, Default$, Answer$
Message = "Copy formulas from left to Right:"
Title = "I got help from mrexcel.com"
Answer = InputBox(Message, Title, Default)
For Each cel In Selection
If cel.Formula Then
cel.Copy
Destination:=Selection.cel.offset(0,-1)
End If
Next
End Sub

any other creative idea, or modification of solution would be greatfull
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

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