Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default parent/child ranges

#1 question - does VBA automatically know that the 1st workbook (that
contains the sub) is the parent, & subsequent workbook(s) opened are
the child?? or do i have to tell it that?

i have a large list of non-contiguous range data that needs to be
transferred between 2 workbooks (from parent to child). parent &
child's set-ups are NOT similar.

i tried this approach, first...
Sub testing()
'wb = ezmarkbook
'ws = ezmarkbook.dataentry.page
'newwb = student profile
'newws = student profile.unit page

Set wb = ActiveWorkbook
Set ws = ActiveSheet

Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"

Set newWB = ActiveWorkbook
Set newWS = ActiveSheet

Call copy

End Sub



Public Sub copy()

Set rHere = wb.ws
Set rThere = newWB.newWS

rThere.Range("h8") = rHere.Range("f3")
rThere.Range("c7") = rHere.Range("e3")

col.copy Destination:=myNewRange

End Sub


obviously, this doesn't work. you can see that i was trying to
shorten the amount of typing i would have to do. maybe they should be
sThere & sHere???

rThere.range instead of newwb.newws.range

but like i said, it isn't working. in researching it i stumbled
across the parent-child concept.

there is no rhyme or reason for making a for-each-next loop, so i'll
have to tell each range specifically where it goes. could somebody
please give me some direction on if this is possible to shorten up or
not?
thanks a lot!
susan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default parent/child ranges

I am not sure where you stumbled across the parent child concept, but to the
best of my knowledge there is no such relationship between workbooks opened
in the same instance of excel. from and object perspective, all workbooks
are children of the application object and sheets are children of the
workbook object of their respective workbooks.

Thisworkbook refers to the workbook that contains the code.

Activeworkbook to the workbook that currently has the focus in Excel.

Sub testing()
Dim wb as Workbook, ws as Worksheet
Dim newWb as Workbook, ws as NewWs



Set wb = ThisWorkbook
wb.activate
Set ws = ActiveSheet

Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"

Set newWB = ActiveWorkbook
Set newWS = ActiveSheet

Call copy ws, newws

End Sub

Public Sub copy(Here as Worksheet, There as Worksheet)

There.Range("h8") = Here.Range("f3")
There.Range("c7") = Here. Range("e3")

'col.copy Destination:=myNewRange

End Sub

--
Regards,
Tom Ogilvy



If your code opens workbooks, then you could maintain a reference to them in
your code.

--
Regards,
Tom Ogilvy


"Susan" wrote:

#1 question - does VBA automatically know that the 1st workbook (that
contains the sub) is the parent, & subsequent workbook(s) opened are
the child?? or do i have to tell it that?

i have a large list of non-contiguous range data that needs to be
transferred between 2 workbooks (from parent to child). parent &
child's set-ups are NOT similar.

i tried this approach, first...
Sub testing()
'wb = ezmarkbook
'ws = ezmarkbook.dataentry.page
'newwb = student profile
'newws = student profile.unit page

Set wb = ActiveWorkbook
Set ws = ActiveSheet

Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"

Set newWB = ActiveWorkbook
Set newWS = ActiveSheet

Call copy

End Sub



Public Sub copy()

Set rHere = wb.ws
Set rThere = newWB.newWS

rThere.Range("h8") = rHere.Range("f3")
rThere.Range("c7") = rHere.Range("e3")

col.copy Destination:=myNewRange

End Sub


obviously, this doesn't work. you can see that i was trying to
shorten the amount of typing i would have to do. maybe they should be
sThere & sHere???

rThere.range instead of newwb.newws.range

but like i said, it isn't working. in researching it i stumbled
across the parent-child concept.

there is no rhyme or reason for making a for-each-next loop, so i'll
have to tell each range specifically where it goes. could somebody
please give me some direction on if this is possible to shorten up or
not?
thanks a lot!
susan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default parent/child ranges

thank you very much for explaining it, and showing me how i could use
the () in the copy sub to indicate which WS is which!
i figured there had to be a way, i just wasn't finding it.

actually, it was one of YOUR answers i had looked at! :)
http://groups.google.com/group/micro...16daca63042347

but i may have misunderstood what i was reading.
thanks again!
susan


On May 4, 11:11 am, Tom Ogilvy
wrote:
I am not sure where you stumbled across the parent child concept, but to the
best of my knowledge there is no such relationship between workbooks opened
in the same instance of excel. from and object perspective, all workbooks
are children of the application object and sheets are children of the
workbook object of their respective workbooks.

Thisworkbook refers to the workbook that contains the code.

Activeworkbook to the workbook that currently has the focus in Excel.

Sub testing()
Dim wb as Workbook, ws as Worksheet
Dim newWb as Workbook, ws as NewWs

Set wb = ThisWorkbook
wb.activate
Set ws = ActiveSheet

Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"

Set newWB = ActiveWorkbook
Set newWS = ActiveSheet

Call copy ws, newws

End Sub

Public Sub copy(Here as Worksheet, There as Worksheet)

There.Range("h8") = Here.Range("f3")
There.Range("c7") = Here. Range("e3")

'col.copy Destination:=myNewRange

End Sub

--
Regards,
Tom Ogilvy

If your code opens workbooks, then you could maintain a reference to them in
your code.

--
Regards,
Tom Ogilvy



"Susan" wrote:
#1 question - does VBA automatically know that the 1st workbook (that
contains the sub) is the parent, & subsequent workbook(s) opened are
the child?? or do i have to tell it that?


i have a large list of non-contiguous range data that needs to be
transferred between 2 workbooks (from parent to child). parent &
child's set-ups are NOT similar.


i tried this approach, first...
Sub testing()
'wb = ezmarkbook
'ws = ezmarkbook.dataentry.page
'newwb = student profile
'newws = student profile.unit page


Set wb = ActiveWorkbook
Set ws = ActiveSheet


Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"


Set newWB = ActiveWorkbook
Set newWS = ActiveSheet


Call copy


End Sub


Public Sub copy()


Set rHere = wb.ws
Set rThere = newWB.newWS


rThere.Range("h8") = rHere.Range("f3")
rThere.Range("c7") = rHere.Range("e3")


col.copy Destination:=myNewRange


End Sub


obviously, this doesn't work. you can see that i was trying to
shorten the amount of typing i would have to do. maybe they should be
sThere & sHere???


rThere.range instead of newwb.newws.range


but like i said, it isn't working. in researching it i stumbled
across the parent-child concept.


there is no rhyme or reason for making a for-each-next loop, so i'll
have to tell each range specifically where it goes. could somebody
please give me some direction on if this is possible to shorten up or
not?
thanks a lot!
susan- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default parent/child ranges

The parent and child references in that post were whimsical in nature, used
to suggest one being a subset of the other.

--
Regards,
Tom Ogilvy


"Susan" wrote:

thank you very much for explaining it, and showing me how i could use
the () in the copy sub to indicate which WS is which!
i figured there had to be a way, i just wasn't finding it.

actually, it was one of YOUR answers i had looked at! :)
http://groups.google.com/group/micro...16daca63042347

but i may have misunderstood what i was reading.
thanks again!
susan


On May 4, 11:11 am, Tom Ogilvy
wrote:
I am not sure where you stumbled across the parent child concept, but to the
best of my knowledge there is no such relationship between workbooks opened
in the same instance of excel. from and object perspective, all workbooks
are children of the application object and sheets are children of the
workbook object of their respective workbooks.

Thisworkbook refers to the workbook that contains the code.

Activeworkbook to the workbook that currently has the focus in Excel.

Sub testing()
Dim wb as Workbook, ws as Worksheet
Dim newWb as Workbook, ws as NewWs

Set wb = ThisWorkbook
wb.activate
Set ws = ActiveSheet

Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"

Set newWB = ActiveWorkbook
Set newWS = ActiveSheet

Call copy ws, newws

End Sub

Public Sub copy(Here as Worksheet, There as Worksheet)

There.Range("h8") = Here.Range("f3")
There.Range("c7") = Here. Range("e3")

'col.copy Destination:=myNewRange

End Sub

--
Regards,
Tom Ogilvy

If your code opens workbooks, then you could maintain a reference to them in
your code.

--
Regards,
Tom Ogilvy



"Susan" wrote:
#1 question - does VBA automatically know that the 1st workbook (that
contains the sub) is the parent, & subsequent workbook(s) opened are
the child?? or do i have to tell it that?


i have a large list of non-contiguous range data that needs to be
transferred between 2 workbooks (from parent to child). parent &
child's set-ups are NOT similar.


i tried this approach, first...
Sub testing()
'wb = ezmarkbook
'ws = ezmarkbook.dataentry.page
'newwb = student profile
'newws = student profile.unit page


Set wb = ActiveWorkbook
Set ws = ActiveSheet


Workbooks.Open Filename:="F:\Susan\SchoolProject.xls"


Set newWB = ActiveWorkbook
Set newWS = ActiveSheet


Call copy


End Sub


Public Sub copy()


Set rHere = wb.ws
Set rThere = newWB.newWS


rThere.Range("h8") = rHere.Range("f3")
rThere.Range("c7") = rHere.Range("e3")


col.copy Destination:=myNewRange


End Sub


obviously, this doesn't work. you can see that i was trying to
shorten the amount of typing i would have to do. maybe they should be
sThere & sHere???


rThere.range instead of newwb.newws.range


but like i said, it isn't working. in researching it i stumbled
across the parent-child concept.


there is no rhyme or reason for making a for-each-next loop, so i'll
have to tell each range specifically where it goes. could somebody
please give me some direction on if this is possible to shorten up or
not?
thanks a lot!
susan- Hide quoted text -


- Show quoted text -




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
parent/child relationship between rows? Doug Excel Worksheet Functions 4 April 22nd 23 07:41 PM
Creating child worksheet from parent Vibeke Excel Worksheet Functions 7 July 9th 09 04:34 AM
finding multiple parent-child relationships? Keith R Excel Worksheet Functions 4 April 16th 07 04:13 PM
Windows browser Parent/Child structure ERK New Users to Excel 2 December 3rd 06 12:44 AM
Sorting Parent Child kcmtnbiker Excel Worksheet Functions 2 March 31st 06 01:54 AM


All times are GMT +1. The time now is 08:06 PM.

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

About Us

"It's about Microsoft Excel"