Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
a way to make this more compact ??
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.... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
a way to make this more compact ??
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.... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
a way to make this more compact ??
ty gary this seems what i was looking for, i will add it to my page soon
"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.... |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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.... |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
a way to make this more compact ??
hi gary it works perfectly and it is easyest to reduce if u don't need 800...
but at equivalent parameters it uses 5.5 instead 4.5 cpu usage !!! ;) i will keep it anyway and probably use it, byyy and 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.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
compact Access DB from Excel | Excel Programming | |||
This formula needs to be more compact. | Excel Worksheet Functions | |||
Compact Workbook | Excel Discussion (Misc queries) | |||
Compact | Excel Programming | |||
Compact Excel Spreadsheet | Excel Programming |