Note: The other languages of the website are Google-translated. Back to English
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako v Excelu ponoviti ali zviti makro vsakih X minut?

Med delom z Microsoft Excelom boste morda morali ustvariti makre, da boste lahko izvedli nekatere operacije. Na primer, želite ustvariti makro za samodejno kopiranje vrste podatkov na novo mesto. Ker se bodo podatki pogosto spreminjali, morate ta makro samodejno zagnati vsakih 5 minut, ne da bi ga ročno sprožili, da sinhronizirate ta dva obsega podatkov. Kako to doseči? Metoda v tem članku vam lahko pomaga.

Ponovite ali znova naredite makro vsakih X minut v Excelu


Ponovite ali znova naredite makro vsakih X minut v Excelu

Naslednja koda VBA vam lahko pomaga ponoviti makro vsakih X minut v Excelu. Naredite naslednje.

1. Pritisnite druga + F11 tipke hkrati, da odprete Microsoft Visual Basic za aplikacije okno.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, kliknite Vstavi > Moduli. Nato kopirajte in prilepite spodnjo kodo VBA v Koda okno. Oglejte si posnetek zaslona:

Koda VBA: Ponovite ali zaženite makro vsakih X minut v Excelu

Sub ReRunMacro()
Dim xMin As String

'Insert your code here
    xMin = GetSetting(AppName:="Kutools", Section:="Macro", Key:="min", Default:="")
    If xMin = "Exit" Then
    SaveSetting "Kutools", "Macro", "min", "False"
    Exit Sub
    End If
    If (xMin = "") Or (xMin = "False") Then
      xMin = Application.InputBox(prompt:="Please input the interval time you need to repeat the Macro", Title:="Kutools for Excel", Type:=2)
      SaveSetting "Kutools", "Macro", "min", xMin
    End If
    If (xMin <> "") And (xMin <> "False") Then
      Application.OnTime Now() + TimeValue("0:" + xMin + ":0"), "ReRunMacro"
    Else
      Exit Sub
    End If
End Sub

Opombe: V kodi zamenjajte to vrstico „Vnesite kodo sem s kodo, ki jo boste izvajali vsakih X minut.

3. Pritisnite F5 tipko za zagon kode. V pojavnem oknu Kutools za Excel v pogovorno okno vnesite interval, na katerem boste ponovili makro, in nato kliknite OK . Oglejte si posnetek zaslona:

Od zdaj naprej se bo določen makro ponavljal vsakih 5 minut v vaši delovni knjižici.

Opombe: Če morate ustaviti izvajanje makra in spremeniti interval cikla, kopirajte spodnjo kodo VBA v isto Moduli okno in pritisnite F5 tipko za zagon kode. Nato se makro ustavi. Znova zaženite zgornjo kodo, da določite nov interval.

Koda VBA: ustavite izvajanje makra

Sub ExitReRunMacro()
SaveSetting "Kutools", "Macro", "min", "Exit"
End Sub

Zavihek Office - brskanje, urejanje in upravljanje delovnih zvezkov v Excelu z zavihki:

Office Tab prinaša vmesnik z zavihki, kot ga vidimo v spletnih brskalnikih, kot so Google Chrome, nove različice Internet Explorerja in Firefox, v Microsoft Excel. To bo orodje za prihranek časa in nenadomestljivo pri vašem delu. Glejte spodnjo predstavitev:

Kliknite brezplačno preskusno različico zavihka Office!

Zavihek Office za Excel


Sorodni članki:


Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50% in vsak dan zmanjša na stotine klikov z miško!
dno pisarniške mize
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    crystal · 3 months ago
    @creativeperson97 Good day,
    You need to remove the Sub line and the End Sub line from your code.
    Sub Refresh() ' ' Refresh Macro ' ' Sheets("Sheet1").Select ActiveWorkbook.RefreshAll Sheets("Pivot-Dash").Select End Sub
    Change to:
    ' ' Refresh Macro ' ' Sheets("Sheet1").Select ActiveWorkbook.RefreshAll Sheets("Pivot-Dash").Select

  • To post as a guest, your comment is unpublished.
    creativeperson97 · 3 months ago
    I am pasting the code below in which I have replaced the line to enter the code with my code. The error I am getting is- Compile error: Expected End Sub. Kindly help.

    Sub ReRunMacro()
    Dim xMin As String
    Sub Refresh()
    '
    ' Refresh Macro
    '

    '
    Sheets("Sheet1").Select
    ActiveWorkbook.RefreshAll
    Sheets("Pivot-Dash").Select
    End Sub


    xMin = GetSetting(AppName:="Kutools", Section:="Macro", Key:="min", Default:="")
    If xMin = "Exit" Then
    SaveSetting "Kutools", "Macro", "min", "False"
    Exit Sub
    End If
    If (xMin = "") Or (xMin = "False") Then
    xMin = Application.InputBox(prompt:="Please input the interval time you need to repeat the Macro", Title:="Kutools for Excel", Type:=2)
    SaveSetting "Kutools", "Macro", "min", xMin
    End If
    If (xMin <> "") And (xMin <> "False") Then
    Application.OnTime Now() + TimeValue("0:" + xMin + ":0"), "ReRunMacro"
    Else
    Exit Sub
    End If
  • To post as a guest, your comment is unpublished.
    crystal · 9 months ago
    @LIMCA Hi LIMCA,
    Sorry for the inconvenience. The code does not support entering decimals.

    Please stop the the looping by running the below VBA code, and then rerun the looping code and enter 1 into the popping up dialog box.

    Sub ExitReRunMacro()
    SaveSetting "Kutools", "Macro", "min", "Exit"
    End Sub
  • To post as a guest, your comment is unpublished.
    LIMCA · 9 months ago
    Hi Jack,
    By mistake I entered 0.5 mins and it shows an error,
    I mean xMin is taken as 0.5 minutes.
    How to get rid and change it to 1 min?

  • To post as a guest, your comment is unpublished.
    David · 10 months ago
    @crystal Hey, Thanks! but im afraid the marco doenst even run, when I press F5 excel sends me this error msgs: Run time error 13 'Type Missmatch".

    I deleted it, but If I try to create it again the same error msg appears, my only guess is that I set the time as 0.5 and in the code, so no idea how to modify it now.

    Thanks Again for your help.
  • To post as a guest, your comment is unpublished.
    MOhammed · 10 months ago
    How to create a macro in excel with continuous loop and pressed key would be only pg up and pg down
  • To post as a guest, your comment is unpublished.
    crystal · 10 months ago
    @David Hi David.
    As we mentioned at the end of the post, if you need to stop the execution of the macro and change the interval of the cycle, please copy the below VBA code into the same Module window and press the F5 key to run the code. Then the Macro will be stopped, please rerun the above code to specify a new interval.

    Sub ExitReRunMacro()
    SaveSetting "Kutools", "Macro", "min", "Exit"
    End Sub
  • To post as a guest, your comment is unpublished.
    crystal · 10 months ago
    @Padma Hi Padma,
    The "insert your code here" indicate the VBA code you use to achieve some operation in Excel. Supposing you need to apply VBA to move a row to another sheet based on a specific value, and want to run the code every X minutes automatically, you need to place the VBA code here.
  • To post as a guest, your comment is unpublished.
    davart · 10 months ago
    Hi very useful, however I think I messed up and set the time as 0.5 and now I cannot chage it, any ideas how to change the xMin Setting?
  • To post as a guest, your comment is unpublished.
    David · 10 months ago
    Hi, I messed up and set the time as 0.5 and now I cannot chage it, any ideas how to change the xMin Setting?
  • To post as a guest, your comment is unpublished.
    Padma · 10 months ago
    Hello, Just help me out on "insert your code here". I am a novice and need help on what to fill and how ! Thanks
    I am not getting it right

  • To post as a guest, your comment is unpublished.
    Mohit · 1 years ago
    Hey

    I have a query, your codes works perfectly fine and copies the data in my next columns every 5 minutes but after 3 hours all my columns get full as it is 2003 excel. Could you please help me with a code to check if no other column is vacant then create a new sheet and copy paste data into that sheet
  • To post as a guest, your comment is unpublished.
    crystal · 1 years ago
    @ram2093@gmail.com Hi,
    Please change the line "Application.OnTime Now() + TimeValue("0:" + xMin + ":0"), "ReRunMacro"" to
    Application.OnTime Now() + TimeValue("0:" + "0:" + xMin), "ReRunMacro"
  • To post as a guest, your comment is unpublished.
    ram2093@gmail.com · 1 years ago
    Please provide a Code for :


    "How to repeat or loop a Macro every X Seconds in Excel"


    Thank you
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @ebolshakovv@gmail.com Good daty,
    A new VBA code which can stop the macro has been added at the end of the article. Please have a try. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Jack Hi Jack,
    My mistake.
    A new VBA code which can stop the macro has been added at the end of the article. Please have a try. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    ebolshakovv@gmail.com · 2 years ago
    Tell me more how to stop the execution of the macro and change the interval of the cycle?
  • To post as a guest, your comment is unpublished.
    jack1 · 2 years ago
    Tell me more how to stop the execution of the macro and change the interval of the cycle?
  • To post as a guest, your comment is unpublished.
    Jack · 2 years ago
    @crystal Good day! I did not understand how to break the macro code to set the loop execution time again.Could you describe in more detail how to do this? Where is the value of the run cycle time recorded?
  • To post as a guest, your comment is unpublished.
    Ryan · 2 years ago
    Hi!
    This is great, but is there a way to get it to loop back up to the first row of the spreadsheet before beginning again?


    Thanks!
  • To post as a guest, your comment is unpublished.
    crystal · 3 years ago
    @JIm Good Day,
    Just break the code and run it again.
  • To post as a guest, your comment is unpublished.
    JIm · 3 years ago
    Thanks for this, works a treat. I'm a novice to coding so please forgive me if this is simple...

    How do I get the dialog box to appear again? I have it stuck on a 1 minute loop. Thanks.
  • To post as a guest, your comment is unpublished.
    crystal · 3 years ago
    @primeacademyresource@gmail.com Good Day,
    You can get into the Code window to break the code (click on the Break button) manually to stop the loop.
  • To post as a guest, your comment is unpublished.
    primeacademyresource@gmail.com · 3 years ago
    Great one! Please how do i stop the loop after say 10 times?