View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Divide one range with another

Hi,

Try this

For Each c In Range("A1:a10")
c.Offset(, 4).Value = (c + c.Offset(, 1)) / (c.Offset(, 2) + c.Offset(, 3))
Next

Mike

"Josip" wrote:

Thank you,
sorry if I was a bit unclear. So, the problem is that I have two sets
of ranges, e.g.:
1. Columns A and B, rows 1 to 10.
2. Columns C and D, rows 1 to 10.

And I want to store this data in a Range variable for later use. Would
it be possible to use something like this:
"Set myRange = Cells(1, 1).Resize(2, 10) / Cells(3, 1).Resize(2, 10)"

Ok, that does not work, but something like that? Or do I need to use
those fore claues?




On Sep 24, 11:25 am, Mike H wrote:
Josip,

Yes tha's possible but your question isn't very clear. What are the ranges
and how do you want the answers produced to be presented. This divides column
A by column C and prints the answer to the immediate window

On Error Resume Next
For x = 1 To 10
Debug.Print Cells(x, 1) / Cells(x, 3)
Next
End Sub

Mike

"Josip" wrote:
Hello,


is there a way in VBA to perform elementwise division on two ranges of
numbers, say A1:B10 and C1:D10? I.e.
A1/C1, A2/C2, ...


Thanks,
J