+ Reply to Thread
Results 1 to 8 of 8

VB Code to pass varaible

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to pass varaible

    Hello:
    Please refer to attached file.
    I have macro called "Import" (Button1) to import the data from another file.
    I need to way to skip some part of the code in "Import" if H=1

    Basically :
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: VB Code to pass varaible

    Try:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VB Code to pass varaible

    .
    Paste in the Sheet Level Module :

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pass varaible

    Hello TMS and Logit:

    I am very sorry that i have not explained in detail.
    Please refer to attached file, Sheet2.
    Let me explain exactly what I am doing.
    I have stores as shown in row 4, Store1,Store2, etc.
    I am using code shown in Sheet2 to import data from Store1, Store2 etc

    There is some code WITHIN Closed workwork which i need to avoid if cell H1 = 1 (from attached sheet)when code opens closed workbook.
    So Basically, I need to pass the value of cell H1 in closed workbook so that i can put the condition to avoid.

    I hope this is clear.
    I am very sorry if it is still confusing.

    Please let me know if any questions.

    Riz
    Attached Files Attached Files
    Last edited by rizmomin; 09-22-2017 at 07:30 PM.

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VB Code to pass varaible

    .
    This is either it or real close to what I believe you are attempting to do :

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pass varaible

    Hello:

    The CLOSED file which opens has OPEN Event, pleas refer to the error which i get..

    My Personal.xlsb file is @ "C:\Users\Riz\AppData\Roaming\Microsoft\Excel\XLSTART" location.

    Not sure what is the problem.

    Let me know if any questions.

    Riz
    Attached Images Attached Images

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VB Code to pass varaible

    .
    To open another Excel workbook from your active workbook using a reference written to cel A1:



    Please Login or Register  to view this content.

    A
    B
    C
    D
    1
    C:\Users\My\Desktop\Blood sugar levels.xlsx
    2
    3
    4
    5




    If you want to hardcode the path in the macro itself (as in your example posted) :

    Please Login or Register  to view this content.
    Last edited by Logit; 09-23-2017 at 04:30 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pass varaible

    Hello Logit:

    Thanks a lot, will try and let you know if any problem.
    Riz

+ 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. Getting a varaible into the macro
    By barrowinfurnace in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2016, 03:59 AM
  2. [SOLVED] Help with the code to pass a variable into the command syntax
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2016, 05:05 PM
  3. [SOLVED] VBA code will not let me pass to next cell
    By Wouldsman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2015, 08:30 AM
  4. [SOLVED] Help with VB Code to pass a selection to another workbook's slicer
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-08-2015, 01:11 AM
  5. [SOLVED] Pass Variable in VB Code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2013, 04:49 AM
  6. assining a varaible to the value in another sheet.
    By shishi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2005, 06:05 PM
  7. [SOLVED] Use varaible for worsheet name in a formule
    By slm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2005, 08:05 AM

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