way i could stop my sheet from flickering everytime i change my cell selection via keyboard/mouse. i checked and this problem is only with code below that i run in view code of my sheet...
PHP
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
On Error GoTo errHandler
If Target.Count > 1 Then GoTo exitHandler
If Target.Address(False, False) = "Z3" Then
Call GoToMatch
Exit Sub
End If
Neither is it because you've turned SU off, and then used 'Select' or 'DoEvents' etc in your code.
When running an update for a QueryTable (once a second), 3 'buttons' (activeX image controls with code behind them) flicker - though I see no reference to selecting and/or screenupdating in my code
Is this purely something about refreshing a querytable that I can't fix?
Is there a subclass or API call I can intercept to stop drawing the images alone?
Code:
Public Sub ActivateConn()
Dim strFilespec As String Dim strConn As String Dim sqlStr As String
Set RecSet = New ADODB.Recordset
[Code] .....
In short, there's no REASON why I couldn't just use the selection_change event to fire the same macros as the buttons but... well... it doesn't look anywhere near as good (I have a thing about making VB apps look as good as the code behind them is smart)
Code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.EnableEvents = False Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim WTH As Long If Target.Row = 19 Then WTH = 1 End If Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True Application.EnableEvents = True End Sub If I comment out the code, my screen doesn't flicker.
In the "Tmp = 1" line I was using the special cells method to color constants red (without selecting anything). When I use that code instead of the "Tmp=1" line, it takes about a second to change cells, and I see the "4 Processors Calculating Message" in Excel when the code fires--even if it's not in row 19.
I'm using a bit of code (below) which is not amazing but which does seem to work, the idea being that entering a number then the active cell relating to that number will be highlighted and the sheeet position will "goto" it to move it into view on the screen. I have adapted this from something in one of my old Workbooks, and I admit it's probably a bit messy!
The problem is, it doesn't seem to always put the returned active cell in the same place, sometimes it's nicely central to the screen, but at others it's right at the top. As the numbers corrrespond to the top line of each little area of 30 rows, I'd like it to to come about 10-12 rows down. I can't seem to get this to work!
Code: Sub FindSection() Dim nm As Integer, txtnum As String, Found As Range txtnum = Application.InputBox(prompt:="Enter a Number") Set myRange = Worksheets("T&M SHEET").Range("K:K")
i have an excel workbook containing approx 20 worksheets. What I would like to do is make the workbook go full screen when the user opens the file and allow the user to save as into the same file path the workbook is stored when closed
Some time ago (not sure how long ago) I created a splash screen that comes up when I first load a particular workbook. There was only one worksheet in the workbook and at that time the data in the worksheet was not so relevant and hardly ever used. That workbook name is "Employees" and the worksheet name is "EmpData". Subsequently, the worksheet ("EmpData") in the workbook "Employees" has became relevant to a new workbook named "Payroll" I created. This workbook is used all the time. It had four different active worksheets.
I realized last week that the data in "EmpData" was very relevant to the work in the "Payroll" workbook so I copied "EmpData" worksheet in it's entirety to the "Payroll" workbook as a fifth worksheet using the same name as before, "EmpData". Now each time I open the "payroll" workbook the splash screen shows up and hangs around for several seconds or longer. It has become quite irritating and I want to delete it.
I have a rather large workbook (30 sheets, 10MB) that has one worksheet with many INDIRECT functions in it (pulling data from the same file, different tabs). I am working to put simple code into the workbook to protect and/or unprotect all worksheets. I have gotten code to work to both protect and unprotect all the sheets, but when I run the unprotect code (see below), and then I go to edit the workbook, data from the sheet with many "indirect" functions temporarily "overwrites" the data on the active sheet (this is fixed when I scroll my mouse over the effected cells). I am developing this workbook for other users, so I'd like to fix this before sending it off to them.
This problem does not happen until after I run the following .....
it would be possible to have text disappear after being displayed in Excel for a while.
My son and I played around with games (helping create a photographic memory, I told the youngster!) on the thing and until yesterday neither of us noticed that clicking the mouse anywhere (actually just clicking it) causes the screen to "freeze" while the code still happily erases the text in the background.
Hitting ESC allows the screen to cath up to the actual code EVEN THOUGH the ESC key is actually disabled from breaking the code.
Is it possible to use VBA to call an existing Excel function? I want to have code that calls up the "Insert - Object" popup window in the same manner as it would if the user clicked the toolbar.
I'm trying to copy all the sheets into a new workbook but the following code does not copy the workbook object called "ThisWorkbook", it does copy ALL the other sheets however.....
The "ThisWorkbook" object appears at the end of the list names "Microsoft Excel Object" after all the sheets are listed in the VBA project explorer, like this.....
A while ago I was playing with an excel balanced scorecard which used various on change events of the cells to change the colour of an object (circle). Recently I have been looking at this again and have learned that I can lose some of the .select tags to improve & reduce the code. What we have now is 20 different PI's, each with an oibject assigned, called 'PISHAPE1' through to 'PISHAPE20'. Originally, the code checked every single controll cell, which could be either red, amber, green or no data, which would be black.
What I have works but I am sure there is a more efficient method, rather than repeating the case red, amber, green etc. The first part of the code is repeated 20 times for the different objects, just changing the shape number.
Dim cel As Range For Each cel In Range("controlcell1").Cells Select Case cel.Text Case "Red" ActiveSheet.Shapes("PISHAPE1").Fill.ForeColor.SchemeColor = 10 Case "Green" ActiveSheet.Shapes("PISHAPE1").Fill.ForeColor.SchemeColor = 3 Case "Amber" ActiveSheet.Shapes("PISHAPE1").Fill.ForeColor.SchemeColor = 51 Case "No Data" ActiveSheet.Shapes("PISHAPE1").Fill.ForeColor.SchemeColor = 0 'etc. Case Else End Select Next
SO following on from above, the next code for PISHAPE2 is as follows:........................
Is it possible to make a textbox or combobox the reference of a formula in a cell? I know that you can just do this on VBA, but if possible I don't want to do that in this particular case.
I have written some code that copies certain cells from a spreadsheet constructed form back to a master spreadsheet database. The idea being to prevent users of the form from accessing the database and mucking it up. I write it the long way round and am now trying to modify it to not have to open and close the database everytime BUT whenever I change it I get errors that I think relate to the code not understanding the change of object...
' 3. send updated data to the database (all yellow boxes will update)
' set parameters for cells to copy from Dim r As Long, e4 As Long, e6 As Long, e18 As Long, e20 As Long, e22 As Long, e24 As Long, _ e26 As Long, e28 As Long, e30 As Long, e32 As Long, e34 As Long, e36 As Long, e38 As Long, _ e40 As Long, e42 As Long, e44 As Long, e46 As Long r = Range("D2") e4 = Range("B4") e6 = Range("B6") e18 = Range("B18") e20 = Range("B20") e22 = Range("B22") e24 = Range("B24")
The little blocks of code go on for 17 open/closes!
I recently wrote the following macro to drive several dimensions in a Solidworks assembly using cell values in excel. The strange thing is that I witnessed the macro work on several occassions with the exact same code, however now it always produces "Run-time error 91: Object variable or With block variable not set". I read in another forum that macros in excel can become fragmented with repeated editing, and unloading all the macros then loading everything back up again actually worked for a little while, however I would rather fix an issue with the code if there is one:
Note: In Debug mode the lines
Part.Parameter("D1@Sketch1@CORE INNER.Part").SystemValue = _ Sheets("AEM Core and No Load Loss").Range("B4").Value / 1000
are highlighted
Sub Generate_Core() Set swApp = CreateObject("SldWorks.Application") Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager Part.Parameter("D1@Sketch1@CORE INNER.Part").SystemValue = _ Sheets("AEM Core and No Load Loss").Range("B4").Value / 1000 Part.Parameter("D2@Sketch1@CORE INNER.Part").SystemValue = _ Sheets("AEM Core and No Load Loss").Range("B5").Value / 1000................
I need to identify the object that is triggering the current running macro. For example, i have 4 buttons say button 1 to 4 that all do almost the same thing. I have written 4 different macro for all 4 buttons but i want to simplify my code so that i can have a better leaner code by only using 1 macro for all 4 buttons. simply put is there a way to say identify which button/shape i pressed:
If "identity of button pressed" = "Button1" Then execute some code Else End If
I'm just looking to prevent users from using the print screen or the alt print screen buttons on the keyboard. I have this script that works if I use "39" (Right Arrow)but wont work if I use "42" (Print Screen Button).
I have a macro that checks if a username is in a particular list, and if it is, it unhides certain sheets in the workbook.
The code runs fine if I just run it as a macro or off a command button, but I am trying to execute it when the workbook opens and I keep getting a 57121, Application defined or object defined error.
The code is below;
Private Sub Workbook_Open()
DoEvents
Dim Res1 As VbMsgBoxResult Dim GovRng As Range
For Each GovRng In Sheets("Map").Range("GovernanceMembers") If GovRng.Value = Application.UserName Then Goto 111 Next GovRng
I have a sample spreadsheet (uploaded to this thread) in which I have 10 command buttons named 'Video 1' to 'Video 10'. Next to these buttons is a Windows Media Player Object. I require the code that upon clicking any of the video command buttons, the relevant video is opened and shown in the windows media object within the same sheet (sheet1).
I'm sure the code for each button will be the same apart from the cmd button reference number/name and the link to the file to be played.
If we assume all the videos are called as per their buttons i.e. Video 1.wmv, Video 2.wmv ... Video 10.wmv; and the location of these files is under 'C:Films', can someone post up some code for button 'Video 1' making it clear which variables to change for linking to the different files.
I need my program to: - find the cell containing the string "Datum/Tid" - record the column and the row of the found cell in two variables lCol and lRow
Here is my
Sub test()
Dim rFoundCell As Range Dim lRow As Long Dim lCol As Long
'Find method of VBA Set rFoundCell = Range("A1") Set rFoundCell = Worksheets("Sheet1").Range("A1:Z50").Find(What:="Datum/Tid", After:=rFoundCell, _ LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False)
'for anyof the two lines down I get the message "object variable OR block variable not set"
1) i have office 2003 on a laptop. within powerpoint, i can create a 'microsoft excel chart 11' object. to create a link to the excel data source, do i have to go through the odbc sql setup? it works, but i don't want my powerpoint to be dependent on some excel file somewhere. what are the other options to insert/make a functional pivot chart in powerpoint with the data also within powerpoint? the data as sheet option does not result in the chart being a pivot, it's just a plain chart. it has to be a proper object, not an image paste or a chart that updates links with the excel file open.
2) i have office 2007 on my other laptop. i can not find any suitable object to choose from to make a pivot chart in powerpoint. what's the best way to go about in 2007 version?
3) am i going about this the wrong way with the objects? should i be after vba code?
In one worksheet i have created the following code, which adds date to specific column when data is entered in colum A.
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column = 1 Then Target.Offset(0, 10).Value = Now() End If End Sub
The problem is that when trying to delete a whole row, error message pops-up. Run-time error '1004' Application-defined or object -defined error. When click "End" actually everthing is ok, the row has been deleted, but was just wondering what is causing that error.
I did the restart our company required and when Excel reopened it was on my laptop rather than the big screen. I run 2 screens. Excel 2003 is now so far up on the laptop screen, I cannot move it. I can barely see File, Edit, View, etc. How can I drag Excel down so I can resize it?
I would like to end a macro with a specific cell (e.g. E50) in the first cell in the upper left hand corner of the screen. How might I accomplish this?
I cant get my screen to go all the way to the top of the page! & there is a 2 inch or so area at the bottom of the worksheet as well. I need to get my display back to normal!
I have never created a splash screen and would like to do so now, I am in the VB editor, i have inserted a userform, i would like to insert my company logo on to the userform, how do i do this?