I have a rather tricky situation. I want to append 6 different strings to 6 consecutive cells in a column, then repeat throughout the entire range of the column. Basically, I want
316
316
316
316
316
316
317
317
317
317
317
317
To Become:
TOC_TOT_316
TOC_NEW_316
TOC_ADD_316
TOC_REPAIR_316
316
316
TOC_TOT_317
TOC_NEW_317
TOC_ADD_317
TOC_REPAIR_317
317
317
Right now, my loop looks like this:
I know its probably inefficient. Right now, its adding all those strings to every cell. Basically I need:
to refer to the first 6 cells, and then repeat and do the next 6.
316
316
316
316
316
316
317
317
317
317
317
317
To Become:
TOC_TOT_316
TOC_NEW_316
TOC_ADD_316
TOC_REPAIR_316
316
316
TOC_TOT_317
TOC_NEW_317
TOC_ADD_317
TOC_REPAIR_317
317
317
Right now, my loop looks like this:
Code:
With Myrange
For x = 1 To 6
Select Case x
Case 1
Mystr = "TOC_TOT_"
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
Case 2
Mystr = "TOC_NEW_"
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
Case 3
Mystr = "TOC_ADD_"
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
Case 4
Mystr = "TOC_REPAIR_"
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
Case 5
Mystr = ""
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
Case 6
Mystr = ""
.Offset(0, 1).Columns.Insert
.Offset(0, 1).FormulaR1C1 = "=Concatenate(""" & Mystr & """, RC[-1])"
.Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
.Columns(1).Offset(0, 1).EntireColumn.Delete
End Select
Next
End With
I know its probably inefficient. Right now, its adding all those strings to every cell. Basically I need:
Code:
x = 1 To 6
to refer to the first 6 cells, and then repeat and do the next 6.