a way to make this more compact ??
hi gary ty it seems to work well except for a parenthesis that i added and
works well..
i forgot to tell you how was the dim and set but now i fixed all ty !!
"Gary Keramidas" wrote:
something like this should work. just change the 20 to your last row or use a
lastrow variable if it's all the way down the sheet
Sub test()
Dim ws As Worksheet
Dim i As Long
Set ws = Worksheets("aWS")
For i = 2 To 20 Step 2
With ws
.Range("b" & i).Value = .Range("H7").Value - .Range("A" & i).Value * 100
End With
Next
End Sub
or using the lastrow variable
Sub test2()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("aWS")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow Step 2
With ws
.Range("b" & i).Value = .Range("H7").Value - .Range("A" & i).Value * 100
End With
Next
End Sub
--
Gary
"pls123" wrote in message
...
aWS.Range("B2").Value = (aWS.Range("H7") - aWS.Range("A2").Value) * 100
aWS.Range("B4").Value = (aWS.Range("H7") - aWS.Range("A4").Value) * 100
aWS.Range("B6").Value = (aWS.Range("H7") - aWS.Range("A6").Value) * 100
aWS.Range("B8").Value = (aWS.Range("H7") - aWS.Range("A8").Value) * 100
aWS.Range("B10").Value = (aWS.Range("H7") - aWS.Range("A10").Value) * 100
aWS.Range("B12").Value = (aWS.Range("H7") - aWS.Range("A12").Value) * 100
aWS.Range("B14").Value = (aWS.Range("H7") - aWS.Range("A14").Value) * 100
etc etc....
|