ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA compy base on range (https://www.excelbanter.com/excel-programming/371626-vba-compy-base-range.html)

Ed Dror

VBA compy base on range
 
Hi there,

I'm using Excel 2003 and
I created a Function
Function MyRange() As Integer

MyRange = Worksheets("Sheet1").Range("A1") -
Worksheets("Sheet1").Range("A2")
MsgBox ("The Range is: ") & MyRange
End Function

Now A1 = 30 and A2 = 20 so 30-20=10

Then I want to compy 10 rows base on this results

How do I call MyRange function with my new Sub

Thanks,
Ed Dror
Andrew Lauren



[email protected]

VBA compy base on range
 
If you wanted to copy from (example) A1 to row B10:

Cells(1, 1).Resize(MyRange, 2).copy

Ed Dror wrote:
Hi there,

I'm using Excel 2003 and
I created a Function
Function MyRange() As Integer

MyRange = Worksheets("Sheet1").Range("A1") -
Worksheets("Sheet1").Range("A2")
MsgBox ("The Range is: ") & MyRange
End Function

Now A1 = 30 and A2 = 20 so 30-20=10

Then I want to compy 10 rows base on this results

How do I call MyRange function with my new Sub

Thanks,
Ed Dror
Andrew Lauren



stevebriz

VBA compy base on range
 
Ed,
I am little unsure what you are trying to do here?
Do you want to look at the values in A1 and A2 and then subtract A1
value from A2 to give you the number of rows you want to copy.
Where do you want to copy these 10 rows from eg: what row do you want
to start with eg:
do you want copy the 10 rows from the row number of the A1 value and
then down for the next (A2-A1) rows? or something else?
sorry if this is little confusing ...but I am just trying to work out
what you are trying to achieve here.


Ed Dror wrote:
Hi there,

I'm using Excel 2003 and
I created a Function
Function MyRange() As Integer

MyRange = Worksheets("Sheet1").Range("A1") -
Worksheets("Sheet1").Range("A2")
MsgBox ("The Range is: ") & MyRange
End Function

Now A1 = 30 and A2 = 20 so 30-20=10

Then I want to compy 10 rows base on this results

How do I call MyRange function with my new Sub

Thanks,
Ed Dror
Andrew Lauren



Peter Huang [MSFT]

VBA compy base on range
 
Hi Ed,

Did Steve's understanding and suggestion help you?
If there is any misunderstanding, can you provide more detailed information
about what you are trying to do?

I am glad to be of assistance.

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Ed Dror

VBA compy base on range
 
Hi there,

You can see from this answer

Thanks,
Ed

""Peter Huang" [MSFT]" wrote in message
...
Hi Ed,

Did Steve's understanding and suggestion help you?
If there is any misunderstanding, can you provide more detailed
information
about what you are trying to do?

I am glad to be of assistance.

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.




Peter Huang [MSFT]

VBA compy base on range
 
Hi Ed,

Thanks for your reply and I am sorry I may have confusion in my last post.

I writing the last post to check the status of the issue, it seems that
steve_briz have raised some questions and acampbell012 has given a reply
based on his understanding.

I am also confused by the question, so can you post some detailed
information about what you are trying to do?

Actually to call a function from another Sub is simply as below. But I am
confused by the sentence "Then I want to compy 10 rows base on this
results".

Sub Test()
MyRange
End Sub

Function MyRange() As Integer
MyRange = Worksheets("Sheet1").Range("A1") -
Worksheets("Sheet1").Range("A2")
MsgBox ("The Range is: ") & MyRange
End Function

So if you have any concern on this issue, please feel free to let me know
and I am happy to of assistance.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com