Hi,
I am trying to combine three macro's into one. When I ran the first part by itself in its own macro it would only insert the formulas into the first two rows. Each part of the macro works by itself but not when I combine them into one macro. When I tried to run the macro as you see it I had to shut down Excel and restart. When I first put this together from different parts I found on the internet, it worked. Now I have this problem. Can anybody help please?
Thank you,
Jared Z.
I am trying to combine three macro's into one. When I ran the first part by itself in its own macro it would only insert the formulas into the first two rows. Each part of the macro works by itself but not when I combine them into one macro. When I tried to run the macro as you see it I had to shut down Excel and restart. When I first put this together from different parts I found on the internet, it worked. Now I have this problem. Can anybody help please?
Thank you,
Jared Z.
Code:
Sub Merge_Colums()
Columns("F:G").Insert
Range("F2:F" & Range("E2").End(xlDown).Row).Formula = "=IF(LEFT(E2,1)=""-"",MID(E2,2,LEN(E2)),E2)"
Range("G2:G" & Range("F2").End(xlDown).Row).Formula = "=IF(AND(F2>0,S2>0),F2,IF(AND(F2>0,S2=0),F2,IF(AND(F2=0,S2>0),IF(R2>0,CONCATENATE(R2,""-"",S2),S2),0)))"
Columns("F:F").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.ScreenUpdating = False
Dim cell As Range
ActiveSheet.Cells.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
On Error Resume Next 'in case no text cells in selection
For Each cell In ActiveSheet.Cells.SpecialCells(xlConstants, xlTextValues)
cell.Value = Application.Trim(cell.Value)
Next cell
On Error GoTo 0
Application.ScreenUpdating = True
End Sub