I have an Excel workbook that contains 2 sheets. A VBA code will load a CSV file into the 1st sheet. The VBA code will then plot data from the 1st sheet into charts in the 2nd sheet. This VBA code runs every 5 seconds and causes the charts to flicker.
Anyone has any suggestions to prevent the flickering? I have tried
Application.ScreenUpdating = False
and it does not help.
You can hide the worksheet that has the charts just before you are about to load the CSV data, and then unhide at the end of the second macro.
Have you tried running the macro outside of the VBA editor?
Even if you have set Application.ScreenUpdating = False, this will be ignored if stepping through the code or running from the editor (I believe!)
Related
I have code that loops through sheets of data and creates charts based on each set of data. That works great. But when I added a line to the code to add a black border to each chart (j is the index used to loop through and identify the appropriate chart):
With ActiveSheet.Shapes("MyChart" & j).Line
.ForeColor.ObjectThemeColor = msoThemeColorText1
End With
Excel displays the following message box for each chart being created when I run the code:
"Complex formatting that is applied to the selected chart may take a while to display. Do you want to continue using the formatting?
Yes/No"
The code works fine if I just keep clicking "Yes" for each chart it's creating until the code is finished, but I don't want Excel to ask this at all, I want it to just go ahead with the formatting.
Everywhere I've looked in my research for how to do this says to set:
Application.DisplayAlerts = False
But this isn't working. Excel still displays the Yes/No box every time. Are there other ways to suppress messages/alerts in Excel? Why isn't the above line of code working?
I have a problem with excel in full screen mode. When I chose another sheet (via macro) and go back to previous sheet (via macro) I cant write something to cell selected cell. Any advice?
My code for fullscreen:
Private Sub Workbook_Open()
Application.DisplayFullScreen = True
Application.CommandBars("Full Screen").Visible = False
End Sub
My macro code for select sheet:
Private Sub skok()
Sheets("Sheet 2").Select
End Sub
I can testify that this problem is happening to my workbook also!
To improve visibility, I make the workbook go fullscreen with the DisplayFullscreen=True in the same sub.
Later, the user can move to Sheets 2 with macro in a command button. On sheet 2 there is a button "Save & Return" which runs a macro like
Sheets("Sheet1").select
But when we return to Sheet1 the cells seem to freeze. But the command buttons still work.The situation can be 'unlocked' when I randomly select another sheet below on the sheet tab. Then returning to Sheet1 I can then enter in the cells!
One strange thing is that although the sheet seem freeze, I can still copy & paste text in a cell using the Ctrl+C & Ctrl+V on keyboard.
I have the same problem, and it is an Excel bug! We can still copy/paste values in cells, write in cells by VBA code, but we cannot edit cells' value anymore by double-clicking the cell (or F2). The cell edition is frozen! (It is like unchecking the option "Allow editing directly in cells" (Options->Advanced options-> (Sector)"Editing options".)
To create the bug:
Click on an ActiveX control while you are in full screen mode (Application.DisplayFullScreen = True)
...and the bug is there now you cannot edit cells anymore!
The bug stays as long as the formula bar is not physically visible on your screen (fullScreen or not) and will STOP (as long as you do not recreate the bug...) as soon as the formula bar is displayed (staying in fullScreen and executing "Application.DisplayFormulaBar = True" won't work)
The bug will "temporarily" stop (with hidden formula bar) if you activate another sheet but will start again if you click on any other ActiveX control in any sheets (fullScreen or not)...
The answer is a good lesson in form. Try to avoid .Activate and .Select. If you always specify your ranges you can avoid situations like this with multiple workbooks. Use the format:
Workbooks("myBook.xlsx").Sheets("Sheet1").Range("A1").Value = "whatever"
or:
with Workbooks("myBook.xlsx").Sheets("Sheet1")
.Range("A1").Value = "A"
.Range("A2").Value = 2
.Range("A3").Value = "Blah"
End With
Is there a way to run different macros on several worksheets but, always show sheet1 when the macros are running?
My sheet1 is a cover sheet (a kind of title page) with a command button. Pressing the command button runs macros on a further 5 sheets. Each sub starts by moving to the correct sheet ...
e.g.
Sheets("CDS Data").Select
... but this sheet is shown whilst the macro is running, can I stop this being shown and just show the sheet1 until all macros are finished?
Thanks
Actually ... I have found a way. By starting my macros with;
Application.ScreenUpdating = False
This seems to work.
I am building a small piece of VBA code to update the pivot table automatically so that my chart gets updated. After recording the code, I created stored it in the vb script of the sheet.
Here is my code:
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
I do not want to show the sheet containing the pivot table. So I hide the sheet, and then the code fails to work.
Try changing ActiveSheet to Worksheets("WorksheetName")
So you'd have
Worksheets("WorksheetName").PivotTables("PivotTable2").PivotCache.Refresh
Using ActiveSheet means it performs it on the sheet that is currently selected, last I checked you can't have a hidden sheet selected ;)
Need help to copy range of cells from excel sheet1 to PowerPoint file and paste it as Picture and make that picture fit inside the slide automatically.
I currently use Snagit software to take screenshot of the sheet and use send to powerpoint but it take lots of time.
Any feedback would be nice to automate this process
something like this
Sub BetterPicturePaste()
'...other stuff...
Windows(1).Sheets(1).Range("myrange").Copy
Windows(2).View.PasteSpecial DataType:=ppPasteEnhancedMetafile
End Sub