I have an Excel file in which a Macro function is triggered by pressing a push-button. I need the Macro function to be executed on a time basis (say 10 sec) instead of upon an external action. Can it be done?
I found something similar here VBA - How to select a range in a non-activated worksheet but when I tried to "apply" it, I kept getting an error if the relevant sheet wasn't activated. My code
Code: Dim SearchRange As Range, FindRow As Range Dim column As String, search_string as string column = "K"
What I want to do is to be able to search for a specific value in a specific column on the "Combo boxes" sheet, which isn't activated (the number of rows will never be large, thereof the hard-coded 200).
I get the impression that some sites say the relevant sheet has to be activated, others say it doesn't.
The code above works fine if the sheet is activated, otherwise it fails with error 91 on the msgbox row.
Is there a way to run a macro in an open workbook when the workbook becomes activated or deactivated? So if I have workbook A open with a macro in it and workbook B open as well, can I have the macro run on workbook A when that becomes the workbook I see on my screen?
I have a macro that activates and copies data from a hidden workbook. The problem I'm having is that when the macro is done, the workbook is no longer hidden.
I used this code here to "re-hide" the workbook...
Code: Windows("Macros.xlsm").Visible = False
...but now, everytime, it asks me if I want to save the changes to my workbook. I would like to copy a worksheet from this hidden workbook without having to worry about whether to save changes or not everytime I run this macro.
I have written this code to change the colour of a row of cells to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”: This is the main workbook into which are pulled values from three others. I then want it to open one of the subsidiary workbooks, that feeds the information, to change the same job row to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”. Then I want to save the changes and return to the main sheet: - The ActiveCell contains the Job Number.
Option Explicit Public rw As Integer Public Col As Integer Public Job As String Public JobNo As String Public RowNo As Integer Public wName As String Public times As Integer Public Pips As String Public Nicolas As String Public Cindys As String Public wb
Sub FinishedinOfficeCindy() . rw = ActiveCell.Row JobNo = ActiveCell Col = ActiveCell.Column If Col 1 Then Check that the correct MsgBox "Please choose the Job Number first"column is selected and Exit SubThat the workbook is End Ifthe correct one If Cells(rw, 14) "Cindy" Then MsgBox "Wrong Secretary Chosen - whoops!" Exit Sub End If
All works perfectly when I step through it but, when it is activated (Ctrl+Shift+C) it opens the other workbook and then seems to end? I even tried putting in delays to see if they would help but they didn’t.
I have a small workbook that copies 4 cells to a database list as per the code below, 2 of the fields activate a pop up calendar for date input on a button push the data is transfered to the sheet and the cells are cleared, however on the clear contents parts at the bottom of the code it reactivated the pop up calendar, is there a way of not having this pop up when clearing the contents.
How do I add multiple worksheets at once after opening a new workbook? I was able to go to Insert>Workbook but it only adds one sheet at a time. I I need to add 50 woorksheets, I don't want to really click 50 times.
Insert a new worksheet To add a single worksheet, click Worksheet on the Insert menu. To add multiple worksheets, hold down SHIFT, and then click the number of worksheet tabs you want to add in the open workbook. Then click Worksheet on the Insert menu.
When I hold down the shift button and enter 50 i get the "%" and ) sign entered on the open workbook and then I try to click worksheet from the insert tab and it is greyed out.
I am getting a run time error 1004 during a copy-paste of a named range. I've read other posts and the help file and know it's related to defining an object, but I'm not clear on exactly what hasn't been defined.
Private Sub Worksheet_Activate()
Dim lCell As Range Set lCell = Worksheets("Sheet1").Range("C65536").End(xlUp).Offset(1, 0) ' find first blank cell in the column
With Worksheets("Sheet1").Range("AllDates") 'filter duplicate dates . AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _ "E7"), Unique:=True End With
Worksheets("Sheet1").Range("Dates_Filtered").Copy Destination:=Worksheets("Sheet1").Range("lCell") ' fails on this line Range("Dates_Filtered").Clear
I'm trying to Filter a list by the criteria selected in a listbox, and activated by a command button. My problem is the sort criteria. I have 11 regions, numbered 01EPS through 11EPS. Sorting by any of these criteria works just fine.
The problem is that I also want to be able to sort by ALL of the regions at once. I can do this by using a custom filter. I recorded a macro to see what the difference was, and it simply a matter of changing 01EPS to "=*EPS". However, adding that to my case list results in an error message of "Compile Error: Syntax Error".
I have a macro where I manually select a cell then the macro kicks in to copy and paste the contents into the Find function. From there it goes to another work sheet, clicks on a cell in column one and searches for matching cell contents. Then If false it manually goes back to the original worksheet/cell and then I input a N in the left adjacent cell. If true I enter a Y. Right now I can only run this for the specific cell the macro was recorded for. I would like to expand this.
What I would like to do create a loop in the macro that waits for my cell choice input then continues with the with the Find function. If false the macro should just loop back to the original worksheet/cell and wait for input, ie the next cell selected. However, if true a worksheet/cell is selected, a Y is input and it loops back to the original cell and waits for input.
This is the code I use to call a macro when the macro Im calling is in the same workbook.
However, I would like to call this same macro when using another workbook. I copied the macro "Clearformating" and pasted into a personal macro workbook module. However when I add this code to the sheet tab it will not run the macro.
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
I have a Sheet sheet1 and I want to run a macro when the cell D2 in Sheet1 is equal to 10,7,5,and 3. I only want this macro to run when those values are reached the macro then puts the data onto a sheet called wps. The macro is run as a module and is a sub macro.
Basically, what I'm dealing with is an inventory system. When a cell value reaches below a certain quantity, we have a cell light up with the word "YES" (under the "re-order" column). What I'd like to do is have a macro that checks to see if that cell is populated with "YES" and if it is, to run another macro (which I already have written) that sends out an email notifying us of the need to re-order.
How it would work: The person pulling out the inventory would fill out this form and click "Submit"
I would then have a "call" code tied to the "Submit" button that when clicked, would run the macro to check cell population and send out the email. The email code is already written and works flawlessly on it's own. I just cant seem to figure out how to write a macro that checks for cell value and then runs it (or not) based on that.
I have a macro called "ResultCopyPaste". When it is run it copies and pastes some results. I have a cell C23 that counts how many more results need to be run, copied and pasted. As each result is copied and pasted the count changes. When the count gets to zero nothing else needs to be done.
I want to create a macro that will repeatedly run the "ResultCopyPaste" macro until C23 shows zero. What is the VBA code? Presumably something to do with repeating the macro if C23>0
In case it's relevant the code for the ResultCopyPaste macro is:
Been racking brain, searching through the forum here, and my Excel 2003 Bible all day trying to figure out this problem to no avail. I would like to clear the contents of any cell in a given range if the cell immediately to the right of is formatted as bold.
I have 2 columns and 10 rows (A1:B10). In column A are certain text values. How do I write a macro to go through the table and preform an operation in the corresponding cell in column B depending on the value in cell A? for example, if A3 = "Complete", overwrite the formula in B3 with the value (paste value)?
I have a sheet where i have many differently named areas (like state1_1 and state1_2) When I doubleclick on a cell then a macro should run with following criteria: 1) Macro will run if the doubleclicked cell is part of any range in the list. Here I mean that names of ranges which belong to that list start with word state (like state1_1 and state1_2). No other ranges should not be in that list. If the cell is not in the range that is part of the list, then nothing should happen.
My question: Is it possible to write a code that calls the macro with the name specified in a particular cell? Right now I have some AutoFilter going on making a list that has numbers 1, 2, 3... I also have alot of macros named Search1, Search2, Search3... So I can make a cell, say A28, that combines "Search" with whatever number is in Column C, row 29:
I am attempting to create a ROI calculator for my place of work. I want a blank cell to fill in green or red based a cell below it being equal or greater than 5.0%. What is the Macro or equation to do that?
I have a spreadsheet where if Cell A2 says "Deposit", Rows A2-E2 would be formatted with a Blue background.
I've tried conditional formatting, but I can't built it into a Macro (I can't make it run), and it only highlights the cell that has that value. I also tried having the spreadsheet filter down to only the values I want highlighted, then highlighting all cells and un-filtering the column- this didn't work either.
It would basically say :
If (any cell in Row A) has text = "Deposit" (it needs to be exact, it can't be "containing"), set cell with the word "Deposit" and 4 cells to the right as Blue (I'm not picky about the color).