Editing Code to peform 5 steps to every highlighted cell in a column
Hi, I am trying to change the format of every highlighted/selected cell in a given column. I want to take out an unnecessary "0" using these five steps: 1)=text(cell, "000000000000") 2) Left(cell,5) 3)Right(cell,6) 4) concatenate(left 5 and right 6) 5)value(the concatenated text)
I want to be left with only the column of new numbers (with the deleted "0").
This is what I have so far, and it is not working like I want it to; it will do the proper steps but only to one cell...it deletes any other cells. I am very, very new to VBA.
Thank you for any help!
Sub NDCswitch()
'
' NDCswitch Macro
'
'
ActiveCell.Offset(0, 1).Columns("A:E").EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],""000000000000"")"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],5)"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[-2],6)"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],RC[-1])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
ActiveCell.Offset(0, -5).Columns("A:E").EntireColumn.Select
ActiveCell.Offset(0, 5).Columns("A:A").EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(0, -5).Columns("A:E").EntireColumn.Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(1, 1).Range("A1").Select
End Sub
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago