+ Reply to Thread
Results 1 to 7 of 7

Is there a way to guide the VBA code so that it may just keep shifting from main sheet ...

  1. #1
    Forum Contributor
    Join Date
    12-11-2012
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    308

    Is there a way to guide the VBA code so that it may just keep shifting from main sheet ...

    to an immediate module say Module 1 ( back and forth) and access to other macros in other modules may be through "Form" buttons ? My code in Sheet2 is as follows:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    Hi omega,

    Your question is a little different than your code. In your thread question you ask about shifting from worksheet to worksheet.
    In VBA there are different places to put your code. If it is behind a worksheet (not in a main module) it should only work on THAT sheet.
    If it is in a MODULE that is not behind a worksheet it should work for any sheet.

    To learn more you need to read two websites:
    http://www.cpearson.com/Excel/SheetNameFunctions.aspx
    http://www.cpearson.com/Excel/Scope.aspx

    Understanding where the VBA goes to deal with your problem is important to know.

    I think learning the above linked information will allow you to solve your own question.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    12-11-2012
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    308

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    I am trying to read and understand from sources that you have given. Thanks for the same. But, can you tell me that in the above example if IMMwFU was replaced by its actual content i.e

    Application.EnableEvents = False

    Range("FI109").Copy
    Range("fJ109").PasteSpecial Paste:=xlPasteValues

    Range("FI122:FI124").Copy
    Range("fJ122").PasteSpecial Paste:=xlPasteValues

    Application.EnableEvents = True

    ...... Then will the code run faster ?
    Last edited by omega0010; 08-29-2015 at 01:23 PM.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    Hi omega,

    Look at the cell FJ109 before running your code. If the formula bar shows a formula, it is being calculated. Then after you run the code using "xlPasteValues" look at the cell again. If it now only shows a number then the code has worked as the formula was converted to a value.

    Will the code run faster is a hard question. Most of Excel code runs very fast. Fast enough that it is hard to time. I don't know how to answer this part of the question.

  5. #5
    Forum Contributor
    Join Date
    12-11-2012
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    308

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    Thanks MarvinP ! I don't know much about codes and I do not have any formal "education" on in this subject, But, by Logic I think that If the code is in the Sheets main page then in the original instance of the code as soon as Fj109 <-3 or > 3 then it will have to go to the code which is in another module and then come back to the main sheet code to complete rest of the codes .....BUT in the second instance where in the main sheets code the detail of the code(IMMWFU) is added then it does not have to go to the "other module" to do what it has to AND actually gets it done right away ! What do you think ?
    There is a clear and visible delay in the code as sometimes the lower codes of the main sheet does not get executed ( up-to 2-3 cycles of the "AA" code) and upto 10-15 secs .... Now since you are an expert I will give you another diagnostic tool in this relation. The first code "AA" is actually set to run @ the titration of every 5 seconds ( i.e Now() is copied and if de2 (=Now()-preiously pasted value) > d3(=time(0,0,05)) then the code "AA" runs).
    Is it possible that because of this, the running code is interrupted, and thus the visible delay in the end codes(below like RPRIMM etc) ? All my codes are of similar length except "AA" which takes about 2 secs to execute( I don't know how to check the speed of a macro but this is my observation. I and the other readers will be obliged if there is a reference reading help from you. Thanking you again for your kindness, time and effort ...... God Bless!
    Last edited by omega0010; 08-30-2015 at 01:38 AM.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    Hi omega,

    See if putting in a screenupdating = false statement in your code makes it run faster/better.
    http://www.excel-pratique.com/en/vba...enupdating.php
    Or put a timer in your code and call it between your if statements. Instead of putting the time in a msgbox, send it to the Immediate Window using a Debug.Print statement. This will allow you to see how much time each part of your code is taking. See
    https://www.youtube.com/watch?v=04tN52ubrEE
    for a video of what I'm saying.

  7. #7
    Forum Contributor
    Join Date
    12-11-2012
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    308

    Re: Is there a way to guide the VBA code so that it may just keep shifting from main sheet

    Thanks for your patience and help !
    It is very kind of all of you in the Forum to teach novices like me and others and share your knowledge and experience !

    My GURU who was a very big composer in India said to me " The true owners of wealth and knowledge are those who share it with others !" ... I salute you all and specially the originators and coordinators of this great forum !

+ 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. New code keeps shifting photos up when updating old photo
    By atomichybrid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2015, 06:33 PM
  2. Replies: 1
    Last Post: 03-28-2013, 02:49 PM
  3. Macro code to pull the data from different sheets to main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2012, 09:54 AM
  4. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 AM
  5. [SOLVED] conditional shifting, deleting. VBA/Macro code
    By slxia1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-11-2012, 10:11 AM
  6. Code for range shifting based on month
    By kw42chan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2012, 03:26 AM
  7. Guide for me a code?
    By lunar_star in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2007, 03:47 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