storemannequin
Board Regular
- Joined
- May 29, 2010
- Messages
- 108
The reason I ask is because almost everything that I do in VBA involves looping ad infitium...basically. Would you go about this any other way? I can usually always think of a way to do some sort of manipulation, but it always involves looping!? Is that just because I'm a beginner programmer or is there really no better way of going about certain tasks? Appreciate it greatly!
Code:
Sub SwapAndExtend()
FC = Cells(2, Columns.Count).End(xlToLeft).Column
FR = Cells(Rows.Count, 1).End(xlUp).Row
RowCount = FR - 2
For i = 1 To FC
If Cells(2, i) = "ASP" Then
Columns(i).Cut
Columns(i).Offset(, -1).Insert Shift:=xlToRight
End If
Next i
For e = 1 To FC
If Cells(2, e) = "EXT" Then
Cells(3, e).Resize(RowCount, 1).FormulaR1C1 = "=RC[-2]*RC[-1]"
End If
Next e
For j = 1 To FC
Select Case Cells(2, j)
Case "QTY"
Cells(2, j).Resize(RowCount, 1).NumberFormat = "* #,##0"
Case "ASP"
Cells(2, j).Resize(RowCount, 1).NumberFormat = "$* #,##0.00"
Case "EXT"
Cells(2, j).Resize(RowCount, 1).NumberFormat = "$* #,##0.00"
End Select
Next j
End Sub