VBA compy base on range

  • Thread starter Thread starter Ed Dror
  • Start date Start date
E

Ed Dror

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
 
If you wanted to copy from (example) A1 to row B10:

Cells(1, 1).Resize(MyRange, 2).copy
 
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.
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top