Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much,
c.Offset(, 4).Value = c / c.Offset(, 2) worked perfectly for my needs. On Sep 24, 12:49*pm, Mike H wrote: 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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Glad i could help and thanks for the feedback
"Josip" wrote: Thank you very much, c.Offset(, 4).Value = c / c.Offset(, 2) worked perfectly for my needs. On Sep 24, 12:49 pm, Mike H wrote: 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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actuall, one more thing. Is it possible to store these results in a
Range variable and not justi in cells determined by the offset(,4)? On Sep 24, 1:04*pm, Josip wrote: Thank you very much, c.Offset(, 4).Value = c / c.Offset(, 2) worked perfectly for my needs. On Sep 24, 12:49*pm, Mike H wrote: 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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Unless you need the result in VBA for other reasons
=SUM(A1:B10/C1:D10) Array enter with Ctrl-Shift-Enter Regards, Peter T "Josip" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Divide by the minimum non-zero number in a range of cells | Excel Worksheet Functions | |||
Divide a range of cells by a number | Excel Discussion (Misc queries) | |||
divide all numbers in range by a fixed number | Excel Discussion (Misc queries) | |||
Divide one row over other row I dont wont to divide one number | Excel Discussion (Misc queries) | |||
Divide Expression stops in Macro when Can't divide | Excel Programming |