+ Reply to Thread
Results 1 to 8 of 8

Sheet to sheet activation coding needed

  1. #1
    Registered User
    Join Date
    10-15-2008
    Location
    Spencerport NY
    Posts
    9

    Sheet to sheet activation coding needed

    HI
    I am trying to set up vba as part of a macro that will do the following:
    Open a master workbook
    Open a data workbook( There will be a few of these to process)
    Copy the data from a data workbook sheet (INPUT SHEET) to INPUT SHEET in the master workbook.
    I will rename the master and then continue with the same process for the next data workbook.
    I cannot copy/move the input sheet because of an MS bug whereby all of the sheet coding is lost whe you insert a sheet into a workbook.

    I have set up a sheet in the master workbook that lists all of the data workbook names and paths I set the data workbooks up with a string variable name of TRGT.

    I can get the coding to open the TRGT workbook but am having trouble getting the subsequent sheet commands to work in order to extract the data.

    Here is a snippet of the code:

    Please Login or Register  to view this content.
    From here I want to open the data workbook sheet, select a range of data using sells reference, move the data to the master workbook sheet using the cells reference … then repeat the process with the next range of data. Etc. etc

    I need the “open sheet”( activate, select…) text to flip back and forth between the workbooks.

    Thanks in advance for your help..

    God Bless America !
    Last edited by mrlucky; 10-18-2008 at 06:26 PM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi MrLucky,

    I cannot copy/move the input sheet because of an MS bug whereby all of the sheet coding is lost whe you insert a sheet into a workbook.
    It is good to provide more background to comments like the above by linking to your previous post (even if unresolved) ie
    http://www.excelforum.com/excel-prog...iable-bug.html

    I need the “open sheet”( activate, select…) text to flip back and forth between the workbooks.
    Usually it is not necessary to "activate" or "select" the different workbooks when coding. I suggest you record a macro of your manual actions for one example (compare to my below example*) & then post back with your recorded code if you have further questions...
    *As I put this example together I got a bit carried away & it may even work for you "as is".

    Please Login or Register  to view this content.
    btw, the below code declares the "TRGT" as a variant because the "as string" only relates to the variable immediately before the "as" (this is the same for the MM declaration).
    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    That bug's been corrected for a long time. Are you really still using Excel 97?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    10-15-2008
    Location
    Spencerport NY
    Posts
    9

    Smile Re: sheet to sheet activation response

    Hi Rob

    Thank you so much for your work on this, your info was much more than I was expecting...

    I have working code to copy the data from one input sheet to another input sheet in the same work book.

    Question: Can I substitute these lines to flip back and forth tween the target and the master workbooks, once they are both open? and if so.. how do i define the sheet description since they are both called Input Sheet in each of the workbooks.
    Please Login or Register  to view this content.
    Thanks again.

    God Bless America !
    Last edited by mrlucky; 10-18-2008 at 10:46 AM.

  5. #5
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi,

    Roy, Ive answered the question as the code tags have been added.

    Mr Lucky,
    (edit: I'm not sure who has marked this post as solved, but it is best not to ask another question within a post that is marked as "solved" because you may get no answers.)

    There is usually no need to "flip back & forth between 2 workbooks" as this is normally unnecessary (unless you are manually selecting ranges within your code?) & slows the whole macro down.

    Anyway, have a closer look at my code & you can see the beginnings of an answer to your question there:
    Please Login or Register  to view this content.
    In other words, if the declaration of the worksheet variable explicitly includes the relevant workbook name everything will be fine. An example of this without using an variables is:
    Please Login or Register  to view this content.

    hth
    Rob
    Last edited by broro183; 10-18-2008 at 06:05 PM. Reason: noticed the post was marked as "solved" as I replied to a question.

  6. #6
    Registered User
    Join Date
    10-15-2008
    Location
    Spencerport NY
    Posts
    9

    Smile re:Sheet to Sheet activation response

    Hi Rob.

    Thanks for all of your work on this...Sorry for the posting errors.. a newbie on this board... my humble apologies!

    I marked the question as solved..
    With snips of your responses I developed the coding that works.. See below.

    Please Login or Register  to view this content.
    There are 3 or 4 of these segments in the script.

    Anyway.. that works but alas, the bloody sheet coding is still disappearing in the new copies..

    I have posted a new question regarding the copying of sheet coding from one workbook to another..
    Someone did ask about the virgin of Excel that I am using.. Office 2000.

    I did not know that the bug had been fixed.

    Again, I thank you and the other posters for their input.


    "when you're green you grow, when you're ripe you rot".


    God Bless America !!!

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi,

    I think it will be easier for us to help you if we can see the entire code. Can you please attach a zipped example of the Master file with the code & a "target file" that is being copied from?
    It may also help us suggest some changes to your sheet layout that may prevent the need for the use of "step 2" & allow a single paste.

    Shg,
    I haven't come across the sheet code issue before, since he's using Excel 2000, are there any work-arounds/fixes he can use?
    Also, is it possible to "unsolve" a thread (this one may keep going for a while)?

    Rob

  8. #8
    Registered User
    Join Date
    10-15-2008
    Location
    Spencerport NY
    Posts
    9

    Smile re:SOLVED sheet to sheet activation issues

    Hi Rob

    Let me get back to you in a day or so... The data files are of a confidential, proprietary nature and I can't share them. I believe I can create a simple mock up target sheet and master file that will use the same coding, without having to populate it with confidential data.

    Thanks again


    God Bless America!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. User Input / Processing Sheet
    By jeremymc7 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-23-2008, 02:32 AM
  2. MsgBox to open on sheet activation if cell value = false
    By upod in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2008, 12:23 PM
  3. Divided into Specific Numbers
    By seanyeap in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 05-03-2008, 07:28 AM
  4. using cell content to reference a worksheet tab name in second workbook
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2007, 09:32 AM
  5. Summary Sheet in order by date
    By lacey125 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-20-2006, 05:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1