refreshing formula in a column

victorcarreto

New Member
Joined
Jun 28, 2012
Messages
7
I’ve a Macro to split a cell and shift cells down, as the following:

Code:
[COLOR=#000000][FONT=Arial]Sub SplitCell()[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]Dim s As String, v As Variant, l As Long[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]s = ActiveCell.Value[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]v = Split(s, vbLf)[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]l = UBound(v) - LBound(v) + 1[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]If l > 1 Then[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial] ActiveCell.Offset(1, 0).Resize(l - 1, 1).Insert Shift:=xlShiftDown[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial] ActiveCell.Resize(l, 1).Value = Application.Transpose(v)[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]End If[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]End Sub[/FONT][/COLOR]
And, another macro to join cell bellow with the one above shifting cells up, as the following:

Code:
[COLOR=#000000][FONT=Arial]Sub JoinCellsMoveup()[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]    If ActiveCell.Row > 1 Then[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]        ActiveCell.Offset(-1, 0).Value = ActiveCell.Offset(-1, 0).Text & " " & ActiveCell.Text[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]        ActiveCell.Delete[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]    End If[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]End Sub[/FONT][/COLOR]
When I use these macros, the formula in column C (=Len(A1)-Len(B1) ) loses its reference (from the row I used the macro to below). Is there a way to add an update/refresh of the formula in column C, maybe adding some code to my macros that copy the formula in C1 to the rest of the cells in column C?
I’m also looking for a macro that would do this function itself (update/refresh the formula in column C).
Thank you!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This would Autofill your formula in C1 down column C to the last used row from column B.

Range("C1").AutoFill Destination:=Range("C1:C" & Range("B" & Rows.Count).End(xlUp).Row)
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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