Workbook Variable

  • Hi,

    Two questions really:

    I am trying to assign a variable to represent a number of possible workbook's(full paths and name).

    However im not too sure about the variable type that i should be using,

    Dim SapF As String

    Where SapF is the workbook or

    Dim SapF As workbook

    and is determined by a userform.

    Then i want to open this workbook but not sure about the syntax for the variable.
    Any help much appreciated.

    My code is as follows:

  • Re: Workbook Variable

    OK I would define as string

    I would also use a SELECT CASE rather than lots of IFs (more efficient)

    also as all files nearly identical you could create a mainstay variable and then have a minor exception


  • Re: Workbook Variable


    Why don't you have quotes around the user names eg Neil etc?

    If you don't then VBA will regard them as variables.

    Also why do you need if/select?

    user = sapform.UserBox.Text 
    SapF = "G:\5762x-Reconciliation\57621-LON Reconciliation\Brokerage\SAP Files 2005\SAP DAILY-UPLOAD - " & User & ".xls"


  • Re: Workbook Variable

    because Jane is not the file name - it is Jane N whereas for the other users you could just use the user variable.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!