Lisarella117
New Member
- Joined
- Jun 23, 2011
- Messages
- 4
Hello,
I already used the forum search but nothing could help me.
I have a code which first inserts a new column and then inserts a formula into the first 300 cells of this new row.
Unfortunately the Formula is shown as text, and does not function.
I know that by activating each cell by pressing F2 it works, but as I have to do it for 300 cells in each of 5 sheets, I would appreciate if the macro does it automatically.
Here is the code:
Right now it does not function anymore and I don't know why, because this code a few minutes ago worked...
Thanks for helping me! My VBA book has no solution ..
I already used the forum search but nothing could help me.
I have a code which first inserts a new column and then inserts a formula into the first 300 cells of this new row.
Unfortunately the Formula is shown as text, and does not function.
I know that by activating each cell by pressing F2 it works, but as I have to do it for 300 cells in each of 5 sheets, I would appreciate if the macro does it automatically.
Here is the code:
Sub SAPReportFormatting()
Dim Cell As Range
Range("C1").Select
Selection.EntireColumn.Insert
Range("C1:C300").Select
For Each Cell In Selection
If Cell.Value = "" Then Cells.FormulaLocal = "=Trim(Left(D " & Cell.Row & " ,11))"
Next Cell
Range("C1:C300").Select
For Each Cell In Selection
If Cell.Value = "=Trim(Left(D" & Cell.Row & ",11))" Then Cell.NumberFormat = "General"
Next Cell
End Sub
Right now it does not function anymore and I don't know why, because this code a few minutes ago worked...
Thanks for helping me! My VBA book has no solution ..