I have multiple excel workbooks open at the same time. I need to run a macro on one of them every 15 min but I need to return to the active window when the macro is done. How do I read what window is active then return to it when the macro is done?
dTime = Now + TimeValue("00:15:00")
Application .OnTime dTime, "AutoSave"
Application.DisplayAlerts = False
ActiveWorkbook. SaveAs Filename:="c:excel" & Format(Time, "hhmmss"), FileFormat:=xlCSV
Application.DisplayAlerts = True
I've built a macro to run a loop that opens excel files, prints certain sheets and closes them. I have the macro working - to some degree. here is my code (this is excel):
OldPath = "S:RMBS_Performance_Analytics Analysis1 Staging Folder For Monthly Model Templates2007200704VVDeals" Dim t As Workbook Dim s As String Dim a As Window
With Application.FileSearch .NewSearch .LookIn = OldPath .SearchSubFolders = False .Filename = "*.xls" .MatchTextExactly = True If .Execute() > 0 Then For i = 1 To .FoundFiles.Count s = .FoundFiles(i)
I have 2 problems. First problem is that I am trying to add a function to make the window close once its finished printing. This actually works - but it limits my loop iterations from i = 1 to 2 (so it only runs 2 times and I'm not exactly sure why). If I don't include the statement - this can run for up to 7 - 8 times (these are very large files) then excel runs out of memory. Unfortunately, i can't set the loop to run from i = anything other than one.
So What I would prefer is to be able to make the "ActiveWindow.close" command work - because this way I can run the entire loop. But I'm not sure how to. I tried window referencing, I tried adding a new active Window so when the file opens, its opening in the active window already, but nothing works.
Preferably, I need to be able to reference both windows, as my next macro will involve referencing 2 windows (one static - always open) and the other the loop above.
Dim iStartBook As Long, iNewBook As Long iStartBook = ActiveWindow.Index ActiveWindow.NewWindow iNewBook = ActiveWindow.Index I'm trying to grab the "2" that .NewWindow generates. The above gives 1 both times, despite the obvious 2 in the caption after you run it. So what property works? What does .Index mean here?
I have a worksheet with frozen panes (Row and Column). I have hyperlinks that jump to the this worksheet. Is there anyway to have the window position itself so the active cell is in the upper left corner of my frozen panes?
I compared data between excel worksheets all the time, well recently my computer was upgraded from Windows XP to Windows 7 and since then I have not been able to figure out how to have an Excel file to open in the Excel window selected(or last active window) when I have more than one workbook open. Is there a way to do this?
1. if there's a value in name or names count => must be at least one value in test1 or test2
2. last value in names count must be equal to the sum of trues in B1:B4 Problem Is it possible to identify once any of the cells in A9:D12 are activated that once that range is deactivated I run the check to make sure the constraints are met, and populate default values in the case they are not?
Is it possible to identify once any of the cells in A9:D12 are activated that once that range is deactivated I run the check to make sure the constraints are met, and populate default values in the case they are not?
Trying to figure it out with a some combination of: checking if the last cell I was in was in the range and I am no longer in that range; using the selection change change event?
let's say I run a macro from a button on sheet 3, macro process on sheet 10. Is there a way that the macro would automatically go back to sheet 3? Like a "Back" button on IE. I can't code Sheets("sheet 3").Select because I want it to do the same thing on sheet 4,5,6...
I have found this code by searching witch is perfect
Code: If Target.Cells.Count > 1 Then Exit Sub Application.ScreenUpdating = False Cells.Interior.ColorIndex = 0 With Target 'With the cell that was selected, .EntireRow.Interior.ColorIndex = 8 .EntireColumn.Interior.ColorIndex = 8 End With Application.ScreenUpdating = True
The point is that i want to retain the previous formatting of cells when i select another cell. And also i would like to create a switch to turn the Worksheet_SelectionChange event on and off. The tricky part is here i guess, becouse i would like when turned off to retain the previous formatting also.
The below code opens up the printpreview window. This does not allow to select the correct (or change) printer it will automatic use the default printer.
Is there a way for the code to open the print window so I can change the printer and select number of copies?
Sub Print_Button() Dim ws As Worksheet, cell As Range Set ws = Sheets("main") Set cell = Range("g2000").End(xlUp) Do Until cell.Value "" Set cell = cell.Offset(-1, 0) Loop ws.PageSetup.PrintArea = ("A2:" & cell.Address) ws.PrintPreview End Sub
Below is a macro I'm trying to create. The basically it's supposed to be a quick simple macro to save lots of time. I want to select current tab, move/copy (create copy) to the end....then select the tab I've just copied and copy paste special the values (then rename the tab to todays date) FYI the tab I'm copying is called rebuy shipping.
However, I want to then do the same at a later date with the most recent tab, but with the below code it always selects and copies the original tab:
I am wanting to configure approx 100 drop down boxes to all point to the same range of data, approx 40 names, but once the name has been selected, none of the other drop down boxes will be able to select that name.
eg. range: Dave Mike John Steve
select Dave in drop down box in cell B5. Next cell, B7, I want a drop down box without Dave in it. If i then change my mind, and select Steve in cell B5, it will automatically adjust cell B7 to allow Dave as he is now no longer selected in cell B5.
I need a formula to automatically change the summary column according to the month we are in.
Ie: Last Months Data Nov Dec Jan Feb
1 8 1
7 4 7
9 2 9
'Last Months Data' column should show Dec. However, as we move into February and I complete the 'Jan' column, I would like 'Last Months Data' to automatically change to show Jan's data - is this possible?
I was previously told to use the following formula but this would automatically select the current months data and not the previous months data which is what i need - =INDEX(B2:L2,MONTH(TODAY()))
I am trying to select a shape in a cell and place a cell reference into the shape. I know the cell address, but do not know the shape reference. (The row that the cell and shape reside came from copying the row from another sheet and inserting it into the current sheet). I can not seem to come up with the correct code to accomplish this. Right now I have:
Where r+1 is the row where the line finally resides after insertion and "AW" is the column to the right of the cell where the shape resides.
I have tried to put the cell reference into the shape at the location where it is copied from but the reference is not dynamic and I can not seem to get it to be. Another issue that will arise is that the rows in the new sheet will probably be sorted and I question if the cell reference will follow the shape's new location.
This very simple code brings me to M402 everytime I click on the button.
However, I would like to stay in the same column that I am at the moment when I click the button, and go to row 402. (i.e. if I am in cell "Z56", I would like to be redirected to "Z402" when I click the button.