Results 1 to 17 of 17

Thread: Linking one spreadsheet to another

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Linking one spreadsheet to another

    Hi all,

    How do you link a spreadsheet in one workbook to a tab in another workbook, pass parameters and then manipulate data? I am a newbie, please help.

    Thanks!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Linking one spreadsheet to another

    Through VB6 or through Excel itself?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    You would reference the other sheet/cell in the formula of the cell.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    I am trying to do this in VB

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    What code have you written so far?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    Unfortunately, i trashed out the code i wrote yesterday and i am starting afresh today.
    Is it easier to do this in excel than in VB?

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    Ok heres the formula part in vb 6 code.
    VB Code:
    1. [i]ActiveCell[/i].Formula = Sheet2.Cells(1, 1).Value
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    Thanks for the suggestion . I tried that but could not get what I wanted. I have two separate excel work books. One for the user and the other for administrator. I am trying to create the user application in such a way that when the users login, what they see in the drop down list which is limited to their logon information. Second, when the select a branch from the drop down list and click the update button, then the update function will call the admin portion of the other workbook , perform the calculations based on the branch selected by the user in the user application and then paste the results in the user tab.



    Can you please help?

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    A vb 6 form, correct?

    If so then its a coding issue and not an Excel issue.

    You would be populating your vb6 combo with info from either one or two of the books. So you would open each depending upon the users login.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    Hi,

    I am trying to pass the username & password to the second workbook.
    The code below opens the second workbook but prompts the user for the user name & password. Please help?

    Public Sub update_ws(wb)
    'Dim AppWb As Application
    'Set AppWb = Application.Workbooks.Open("Z:\AcctngBranchBudgets\Branch Profitability Model Update\BranchProfitabilityAdmin.xls")
    'AppWb.Visible = True


    Dim XLWb As Workbook
    Set XLWb = Workbooks.Open("Z:\AcctngBranchBudgets\Branch Profitability Model Update\BranchProfitabilityAdmin.xls")
    Dim XLSheet As Worksheet
    Set XLSheet = XLWb.Sheets(4)
    Dim XLRange As Range
    Set XLRange = XLSheet.Range("a1")
    XLRange.Value2 = 1
    'XLWb.Close
    End Sub

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    This looks like your doing this in Excels VBA?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    There is no UserName option. Only a password option.
    VB Code:
    1. Set XLWb = Workbooks.Open(Filename:="Z:\AcctngBranchBudgets\Branch Profitability Model Update\BranchProfitabilityAdmin.xls", Password:="meow")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    Yes, i am doing it in excel VBA

  14. #14

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    I have two loin forms when the application opens. The first login form is for the app and the second for the database. How do i by pass both logins?

  15. #15

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Linking one spreadsheet to another

    You could just use the same login info for both so the userform login is only presented once.

    It would be allot easier to set an Excel password so it can be passed when opening the file. Then for admin access you could supply the login userform.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    11

    Re: Linking one spreadsheet to another

    Hi there,

    I have adapted a piece of code to allow users to login into the database. I have two types of users, that of student and that of admin. If the admin logs in I want them to be taken to a different form than ordinary users.

    Here is the code i have so far



    Code:
    Private Sub Login_Click()

    'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cboUser) Or Me.cboUser = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.cboUser.SetFocus
    Exit Sub
    End If

    'Check to see if data is entered into the password box

    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.txtPassword.SetFocus
    Exit Sub
    End If

    'Check value of password in tblUsers to see if this
    'matches value chosen in combo box

    If Me.txtPassword.Value = DLookup("Password", "Users", "[UserID]=" & Me.cboUser.Value) Then

    UserID = Me.cboUser.Value

    If Me.cboUser = AdminID Then
    DoCmd.OpenForm "AdminForm"
    Else
    DoCmd.OpenForm "Studentform"
    End If - My attempt at trying to get them to go to different forms!

    'Close logon form and open splash screen

    'DoCmd.Close acForm, "frmLogn", acSaveNo
    'DoCmd.OpenForm "Questions" Just a test to see if it would open a form




    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
    Me.txtPassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
    Application.Quit
    End If


    End Sub

    the problem is that I can get the code to go to one form, but it will always be the same, no matter who logs in admin or student. I want them to go to different forms.


    Code:
    If Me.txtPassword.Value = DLookup("Password", "Users", "[UserID]=" & Me.cboUser.Value) Then

    UserID = Me.cboUser.Value

    If Me.cboUser = AdminID Then
    DoCmd.OpenForm "AdminForm"
    Else
    DoCmd.OpenForm "Studentform"
    End If - My attempt at trying to get them to go to different forms!

    The above code doesnt work - I think the logic is correct but im not sure what syntax to use.. Basically if Admin logs in, load admin form, else load student form. Hope that explains better!


    Any help would be much appreciated

Posting Permissions

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



Click Here to Expand Forum to Full Width