K
kittronald
I'm trying to perform the following with the least amount of code.
1) Test the value of "x" and if TRUE, do the following ...
2) On Sheet1, select column B and insert 4 columns to the right
3) On Sheet1, enter the following text values:
B1 = "SUM"
C1 = "PRODUCT"
D1 = "QUOTIENT"
E1 = "SUMPRODUCT"
4) On Sheet1, enter the following formulas:
B2 =SUM(1,1)
C2 =PRODUCT(1,1)
D2 =QUOTIENT(1,1)
E2 =SUMPRODUCT(1,1)
With Sheet1
If x = "SUM" Then
Columns($B:$B).Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "SUM"
Range("C1").Select
ActiveCell.FormulaR1C1 = "PRODUCT"
Range("C1").Select
ActiveCell.FormulaR1C1 = "QUOTIENT"
Range("D1").Select
ActiveCell.FormulaR1C1 = "SUMPRODUCT"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=SUM(1,1)"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=PRODUCT(1,1)"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=QUOTIENT(1,1)"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(1,1)"
Else
End With
Is there any way to do this with less code ?
- Ronald K.
1) Test the value of "x" and if TRUE, do the following ...
2) On Sheet1, select column B and insert 4 columns to the right
3) On Sheet1, enter the following text values:
B1 = "SUM"
C1 = "PRODUCT"
D1 = "QUOTIENT"
E1 = "SUMPRODUCT"
4) On Sheet1, enter the following formulas:
B2 =SUM(1,1)
C2 =PRODUCT(1,1)
D2 =QUOTIENT(1,1)
E2 =SUMPRODUCT(1,1)
With Sheet1
If x = "SUM" Then
Columns($B:$B).Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "SUM"
Range("C1").Select
ActiveCell.FormulaR1C1 = "PRODUCT"
Range("C1").Select
ActiveCell.FormulaR1C1 = "QUOTIENT"
Range("D1").Select
ActiveCell.FormulaR1C1 = "SUMPRODUCT"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=SUM(1,1)"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=PRODUCT(1,1)"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=QUOTIENT(1,1)"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(1,1)"
Else
End With
Is there any way to do this with less code ?
- Ronald K.