Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "passing" variable trough routine

hi all.
here's my problem.
I've to track down 2 ranges (in one routine), then in the other routine
I use the 2 ranges to paste values I find with the current routine.
my code is wrong, and it's the follow:

(suppose you've numbers in the cells (A1:A4), and in the cell B1)

=============================

Sub ref ()
Range("A1").Copy
Call FindRange(myrangeOrz)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Call FindRange(myrangeVert)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

End Sub

----------------------------------------------------------------
Sub Find Range(ByRef myrangeOrz as Variant, ByRef myrangeVert as Variant)
Range("A1").End(xlToRight).Offset(0,1).Select
Set myrangeOrz = activecell
Range("A1").End(xlDown).Offset(0,1).Select
Set myrangeVert = activecell

End Sub

------------------------------------------------------------------------------------

So, if I work with only myrangeOrz, code's right.
But with the second range, my code's wrong: I think my problem's
about -- Set myrangeOrz = activecell.
How can I assign the right range to my variables and use them in the other
routine ?
helps very appreciated !



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "passing" variable trough routine

Sub ref()
Range("A1").Copy
Range("A1").End(xltoRight)(1,2).PasteSpecial xlValues
Range("A1").End(xldown)(2).PasteSpecial xlValues
End sub

would paste in C1 and A5.

--
Regards,
Tom Ogilvy


"asburypark98" wrote in message
...
hi all.
here's my problem.
I've to track down 2 ranges (in one routine), then in the other routine
I use the 2 ranges to paste values I find with the current routine.
my code is wrong, and it's the follow:

(suppose you've numbers in the cells (A1:A4), and in the cell B1)

=============================

Sub ref ()
Range("A1").Copy
Call FindRange(myrangeOrz)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Call FindRange(myrangeVert)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

End Sub

----------------------------------------------------------------
Sub Find Range(ByRef myrangeOrz as Variant, ByRef myrangeVert as Variant)
Range("A1").End(xlToRight).Offset(0,1).Select
Set myrangeOrz = activecell
Range("A1").End(xlDown).Offset(0,1).Select
Set myrangeVert = activecell

End Sub

--------------------------------------------------------------------------

----------

So, if I work with only myrangeOrz, code's right.
But with the second range, my code's wrong: I think my problem's
about -- Set myrangeOrz = activecell.
How can I assign the right range to my variables and use them in the other
routine ?
helps very appreciated !





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "passing" variable trough routine



"Tom Ogilvy" wrote:

Sub ref()
Range("A1").Copy
Range("A1").End(xltoRight)(1,2).PasteSpecial xlValues
Range("A1").End(xldown)(2).PasteSpecial xlValues
End sub

would paste in C1 and A5.

--
Regards,
Tom Ogilvy


"asburypark98" wrote in message
...
hi all.
here's my problem.
I've to track down 2 ranges (in one routine), then in the other routine
I use the 2 ranges to paste values I find with the current routine.
my code is wrong, and it's the follow:

(suppose you've numbers in the cells (A1:A4), and in the cell B1)

=============================

Sub ref ()
Range("A1").Copy
Call FindRange(myrangeOrz)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Call FindRange(myrangeVert)
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

End Sub

----------------------------------------------------------------
Sub Find Range(ByRef myrangeOrz as Variant, ByRef myrangeVert as Variant)
Range("A1").End(xlToRight).Offset(0,1).Select
Set myrangeOrz = activecell
Range("A1").End(xlDown).Offset(0,1).Select
Set myrangeVert = activecell

End Sub

--------------------------------------------------------------------------

----------

So, if I work with only myrangeOrz, code's right.
But with the second range, my code's wrong: I think my problem's
about -- Set myrangeOrz = activecell.
How can I assign the right range to my variables and use them in the other
routine ?
helps very appreciated !






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "passing" variable trough routine

hi Tom,
thank you for your reply.
It works; but I write this code because in my work
I want to bring both the two ranges in the other routine.
If I use the "select" command, routine remember only the last
range and not the previous.
So how can I bring both ranges from the Sub FindRange() to the
Sub ref() routine ?

regards,
ap98


"Tom Ogilvy" wrote:

Sub ref()
Range("A1").Copy
Range("A1").End(xltoRight)(1,2).PasteSpecial xlValues
Range("A1").End(xldown)(2).PasteSpecial xlValues
End sub

would paste in C1 and A5.

--
Regards,
Tom Ogilvy



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "passing" variable trough routine

Sub ref ()
Range("A1").Copy
Call FindRange(myrangeOrz, myrangeVert)
MyrangeOrz.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

MyRangeVert.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

End Sub

Sub Find Range(ByRef myrangeOrz as Variant, ByRef myrangeVert as Variant)
Set myrangeOrz = Range("A1").End(xlToRight).Offset(0,1)
Set myrangeVert = Range("A1").End(xlDown).Offset(0,1)
End Sub

--
Regards,
Tom Ogilvy



"asburypark98" wrote in message
...
hi Tom,
thank you for your reply.
It works; but I write this code because in my work
I want to bring both the two ranges in the other routine.
If I use the "select" command, routine remember only the last
range and not the previous.
So how can I bring both ranges from the Sub FindRange() to the
Sub ref() routine ?

regards,
ap98


"Tom Ogilvy" wrote:

Sub ref()
Range("A1").Copy
Range("A1").End(xltoRight)(1,2).PasteSpecial xlValues
Range("A1").End(xldown)(2).PasteSpecial xlValues
End sub

would paste in C1 and A5.

--
Regards,
Tom Ogilvy







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "passing" variable trough routine

Thanx a lot Tom!
code works now !


"Tom Ogilvy" wrote:

Sub ref ()
Range("A1").Copy
Call FindRange(myrangeOrz, myrangeVert)
MyrangeOrz.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

MyRangeVert.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

End Sub

Sub Find Range(ByRef myrangeOrz as Variant, ByRef myrangeVert as Variant)
Set myrangeOrz = Range("A1").End(xlToRight).Offset(0,1)
Set myrangeVert = Range("A1").End(xlDown).Offset(0,1)
End Sub

--
Regards,
Tom Ogilvy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
reading variable "from" and "to" ZIP codes Dan Wasser[_2_] Excel Programming 2 January 9th 04 01:36 PM
VBA "Save As Text" Routine? dave_d Excel Programming 0 August 27th 03 02:50 AM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"