Hello everyone,
I was hoping to have some help changing the following code.
I would like the end product to insert a column between a dynamic range of existing columns with the following equation in each cell within the new columns.
The data table start off looking like this:
[TABLE="width: 298"]
<tbody>[TR]
[TD]Well ID[/TD]
[TD]Date Sampled[/TD]
[TD]PCE[/TD]
[TD]TCE[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]1/25/2008[/TD]
[TD]ND<5.0[/TD]
[TD]ND<5.0[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]6/20/2008[/TD]
[TD]ND<5.0[/TD]
[TD]ND<5.0[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]9/23/2008[/TD]
[TD]ND<0.50[/TD]
[TD]ND<0.50[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]11/5/2008[/TD]
[TD]ND<0.50[/TD]
[TD]1.9[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]3/16/2009[/TD]
[TD]ND<0.50[/TD]
[TD]1.6[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]6/2/2009[/TD]
[TD]ND<0.50[/TD]
[TD]1.4[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]9/17/2010[/TD]
[TD]ND<0.50[/TD]
[TD]ND<0.50[/TD]
[/TR]
</tbody>[/TABLE]
And the final product would look like this:
[TABLE="width: 848"]
<tbody>[TR]
[TD="align: center"]Well ID[/TD]
[TD="align: center"]Date Sampled[/TD]
[TD="align: center"]PCE[/TD]
[TD="align: center"][/TD]
[TD="align: center"]TCE[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]1/25/2008[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]6/20/2008[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]9/23/2008[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]11/5/2008[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.9[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]3/16/2009[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.6[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]6/2/2009[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.4[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]9/17/2010[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
</tbody>[/TABLE]
So far I have this:
Thank you in advance for any help you can provide.
I was hoping to have some help changing the following code.
I would like the end product to insert a column between a dynamic range of existing columns with the following equation in each cell within the new columns.
The data table start off looking like this:
[TABLE="width: 298"]
<tbody>[TR]
[TD]Well ID[/TD]
[TD]Date Sampled[/TD]
[TD]PCE[/TD]
[TD]TCE[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]1/25/2008[/TD]
[TD]ND<5.0[/TD]
[TD]ND<5.0[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]6/20/2008[/TD]
[TD]ND<5.0[/TD]
[TD]ND<5.0[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]9/23/2008[/TD]
[TD]ND<0.50[/TD]
[TD]ND<0.50[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]11/5/2008[/TD]
[TD]ND<0.50[/TD]
[TD]1.9[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]3/16/2009[/TD]
[TD]ND<0.50[/TD]
[TD]1.6[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]6/2/2009[/TD]
[TD]ND<0.50[/TD]
[TD]1.4[/TD]
[/TR]
[TR]
[TD]VW-1[/TD]
[TD]9/17/2010[/TD]
[TD]ND<0.50[/TD]
[TD]ND<0.50[/TD]
[/TR]
</tbody>[/TABLE]
And the final product would look like this:
[TABLE="width: 848"]
<tbody>[TR]
[TD="align: center"]Well ID[/TD]
[TD="align: center"]Date Sampled[/TD]
[TD="align: center"]PCE[/TD]
[TD="align: center"][/TD]
[TD="align: center"]TCE[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]1/25/2008[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]6/20/2008[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<5.0[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]9/23/2008[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]11/5/2008[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.9[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]3/16/2009[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.6[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]6/2/2009[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]1.4[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
[TR]
[TD="align: center"]VW-1[/TD]
[TD="align: center"]9/17/2010[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[TD="align: center"]ND<0.50[/TD]
[TD="align: center"]=IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),0,1))[/TD]
[/TR]
</tbody>[/TABLE]
So far I have this:
Code:
Dim i, itotalrows As Integer
Dim strRange As String
itotalrows = ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).Row
Do While i <= itotalrows
i = i + 1
strRange = "A" & i
strRange2 = "A" & i + 1
If Range(strRange).Text <> Range(strRange2).Text Then
Rows(i + 1).Insert
Rows(i + 1).Formula = "IF(ISBLANK([RC]-1),"",IF(ISTEXT([RC]-1),1,0))"
itotalrows = ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).Row
i = i + 1
End If
Loop
Thank you in advance for any help you can provide.
Last edited: