+ Reply to Thread
Results 1 to 16 of 16

get data from one sheet list in another

  1. #1
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63

    get data from one sheet list in another

    Having problems with this vb to display a list of specific cell data from "Sites" sheet on "Addressing" sheet.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    How are you using nodupes in this code? Are you using this as a collection?

    When I step through the code it does not show anything being assigned to nodupes

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Swieduwi,

    You didn't delcare "nodupes" as a collection. You never see an error because of the "On Error Resume Next" statement, which you need to check for duplicates in the collection.

    Add Dim nodupes As New Collection at the begining of your code.

    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    Thanks, Declare would help ... Duh...

    Anyway there is a problem with this code, it's not allowing duplicate dates
    to show up on the list

    Can anyone help me figure this out?
    Code is listed below:

    Please Login or Register  to view this content.
    Last edited by swieduwi; 06-23-2005 at 11:25 AM.

  5. #5
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    There is a problem with this code, it's not allowing duplicate dates
    to show up on the list

    Can anyone help me figure this out?
    Code is listed above:

  6. #6
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    You are missing duplicate dates because a property of using collections is that it is necessary to have unique keys for each item added to the collection. If you have duplicate dates then you key assignments set up duplicate keys.
    You are not seeing this error because of the 'On Error Resume Next'

    If you don't need the key to access the members of your collection then you can eliminate this from your coding.

    idate.Add Item:=ir, key:=CStr(ir)

    becomes

    idate.Add Item:=ir

    HTH

  7. #7
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    Could you help me with the rest of this code ?
    If so, Here is the scoop..

    The first part creates a list of sites from a sheet called "Sites" (Future will be a CSV File not a sheet) to my main workbook sheet called "Addressing"

    this part re-fills all fields when a user clicks on the site list "name"

    For instance, you see a sheet that is a data entry area, standard stuff like
    site name, addresss, contacts ect.. and IP addresses to the right there is a list of sites that are complete. If I want to see info from a previous site, I would click on the site name and all the fields would populate with the data from the "Sites" sheet.

    Does that make any sense?

    So this is what I have come up with, (of course it's not working)
    "Damit Jim, I am a Network Engineer not a programmer", sorry..star trek humor
    Please Login or Register  to view this content.
    Last edited by swieduwi; 06-23-2005 at 01:56 PM.

  8. #8
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    I was able to include just the code needed to do the relist explaination above
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Scott,

    First, aren't your completed sites listed in cells W3:W59 (or where ever the end of the list will be)? Your selection change is currently triggered by E6:E40.
    I changed this to W3:W59 for testing

    Second, as soon as you click on a site name in W3:W59 it tries to clear the contents of H6:I300 which it can't do because some of those cells are merged.
    I commented this line out for testing

    Third, you are comparing the Target.Value of the Site Name selected with column D on the "Sites" list which is actually the Hosp Name.
    I chaged this to compare with column C from your "Site" sheet which contains the Site Names

    Then when you add the item to the Relist Collection what exactly are you trying to add? The code has only a single item being added to that collection which corresponds to the Hosp Name.

    In the For i to Relist.Count loop I'm not exactly sure what you are trying to accomplish with this. The destination Range("H5").Offset(i,0) or
    Range("H5").Offset(i,1) seems to correspond to a Range you currently have populated with the VPN Device Codes (H6) or
    the VPN Device Type for that site (I6)

    It looks like you may have changed the layout of your sheets and things aren't in the same locations as when you first wrote the code?

    Hope this helps to get you started

  10. #10
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    Quote Originally Posted by bhofsetz
    It looks like you may have changed the layout of your sheets and things aren't in the same locations as when you first wrote the code?

    Hope this helps to get you started
    I had found this code on a forum that seem to be what I was looking for, I have been trying to adapt it to my needs, but it's not working.
    I just am not good enough to start from scratch so I was trying to adapt
    Last edited by swieduwi; 06-24-2005 at 07:14 AM.

  11. #11
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Scott,
    Paste this into your sheet module in place of the code you posted earlier.
    I'm still not sure what you want done with the rip1, rip2, rip3, etc. that are on the Sites sheet but I think this pretty much does what you want.

    Please Login or Register  to view this content.
    Brendon

  12. #12
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    Brendon,
    Thanks for your reply.

    I am having a problem with it.
    Error 9
    Subscript out of range

    at this line
    Range("J2") = myArray(0)

    I have not been able to determine what is causing the problem
    but I think it has somthing to do with the declaration of myArray
    Should it be Dim inside the sub or should it be public or global ?
    Last edited by swieduwi; 06-28-2005 at 09:25 AM.

  13. #13
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    It is a module level variable as it is declared at the top of the module. I did this because the function that fills myArray is outside of the sub that calls it. I'm not sure why it's giving you a subscript out of range error. Make sure that you have the declaration at the top of the sheet module.
    The only way I got Error 9 is if I put the declaration inside the sub.
    You can't declare arrays as Public variables.

    Where do the rip1, rip2, rip3 etc. need to be placed on the Address sheet?

  14. #14
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    You are right, Sorry about my placing the Dim statement inside the sub
    It was giving me another error before, but it was due to it not being at the top.
    Thanks,
    Bare with me being a bone head...

  15. #15
    Registered User
    Join Date
    04-08-2005
    Location
    Washington, DC
    Posts
    63
    a question for ya,

    if I select the site and it recalls the data to the screen and I make a change,
    how do I make that change to to the same line ?

    Can I store the line number?

  16. #16
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    I'm not quite sure what you are asking here.
    For example if you change one of the input fields, ie. address, contact, NetScreen, etc. then you will probalby want to use a Worksheet_Change event to see if the value in the cell has been changed and then this can test which cell was changed and if you want the change to be stored in your 'database' (Sites sheet) then you will have to change the appropriate cell on the Sites sheet.
    Alternatively if you want to change the part of the IP address then I might suggest protecting any cells (C10:T27) that have a reference to the four main IP address they are refrencing. That will keep the user from changing a cell that is actually calculating an IP rather for direct input.
    Again if part of the main IP is changed you will most likey want that reflected on your Sites sheet and can do that with a Worksheet_Change event.

    Quote Originally Posted by swieduwi
    if I select the site and it recalls the data to the screen and I make a change,
    how do I make that change to to the same line ?

    Can I store the line number?
    Which line number do you want to store? The line number on the Address sheet where the change was made or the line number where the information was pulled off of the Sites sheet?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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