Debug Statement
Dec 5, 2008
I am trying to put together an automation. I am having problem debuging the code. I am trying to have the automation autofilter with "Interior" and "Exterior" at column P. I am using a statement as follow to pick the cell that is showing at at second row each time after the autofilter ran. (the first row of Exterior and Interior are different) However, when i pick Exterior, the automation was able to locate the second cell after picking Exterior, but when I try Interior, then i will have a debug meesage.
Range("Q2:Q" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(12)(1).Select
The code that I used is as follow:
Sub Macro4()
Range("L1").Activate
Selection.AutoFilter
' Selection.AutoFilter
Selection.AutoFilter Field:=15, Criteria1:="=*Fixture*", Operator:=xlAnd
Selection.AutoFilter Field:=16, Criteria1:="="
Range("P2:P" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(12)(1).Select
ActiveCell.FormulaR1C1 = _
View 9 Replies
ADVERTISEMENT
Sep 23, 2009
Why does this give me a debug error?
View 4 Replies
View Related
May 9, 2008
I have a problem with a HUGE macro project I'm working on. The macro itself isn't huge, but it's being applied to about 10,000 files. The macro is updating information on three spreadsheets in each workbook, but the problem is that the password protection (and Macro in general) fails to unlock when the password was entered in UPPERCASE. So the password is "king" and/or "KING" depending on the sheet. There is no way of predicting which sheets will be caps and which will not, but it's frustrating when my macro stops every 5 files with an error because of a wrong password (even though it's always one of those two).
Is there an IF THEN statement or something that I can do so that the macro doesn't stall every 30 seconds to 2 minutes... I have 10,000 files to crawl through.
View 10 Replies
View Related
Jun 22, 2009
I have a working Excel 2007 macro that accesses two worksheets. I then added a third worksheet and want to access it from the macro. I get a debug error 13 Type Mismatch when the macro tries to access the third worksheet. I know I need to add the third worksheet on a pop-up but I don't remember how to open it.
View 14 Replies
View Related
Dec 15, 2009
When I debug this script I get: division by zero!
In 3 lines over the debugging line, the script are writing out the variable "prosentref" as 1. Whatt can be wrong?
(the value in cell T8769 is 1)
Option Explicit
Sub optimaliseringDrift()
Dim Pgm1 As Integer
Dim Pgm2 As Integer
Dim PL As Integer
Dim lamda_gm1 As Double
Dim lamda_gm2 As Double
Dim deriv1 As Double
Dim deriv2 As Double
Const Pgm1_max As Integer = 200
Const Pgm2_max As Integer = 300
Const Pgm1_min As Integer = 45
Const Pgm2_min As Integer = 40
Const deltaP As Integer = 5
View 9 Replies
View Related
May 29, 2009
trying to copy some records across from once sheet to another?
butt it keeps debugging?
any idea why.
i'd like to keep the user defined type because it's neat and is good practice for myself?
View 9 Replies
View Related
Aug 23, 2006
If a user decides to hit the esc key right in the middle of one of my procedures (bug free, etc), this will leave the file in an odd state. The file is set up so if the routine is re-run it cleans the file up and restores it to proper form.
But hitting esc exposes my code which is password protected when the file is idle. I employ a little trick that makes it hard to hack into my worksheet code, but one achilles heel is the esc button.
What I want is to have the file close if the routine is stopped in mid stream. This way the code is not exposed, and the user cannot monkey with the file.
I wanted to set the file up where i have a custom debug window that when a button is pressd the file closes OR when the user escapes out of the debug window the file closes as well.
View 9 Replies
View Related
Feb 15, 2007
What I'm doing in this script is taking a whole bunch of variables and pasting them into a seperate sheet "Checks" which will construct a cashiers check. The problem is where I've highlighted the code in red. At that point I have copied the Vendor name to the clipboard - I then go to the "Vendor Info" page and search for that Vendor name. If that name exists on the page it works perfectly...moving one column to the right, grabbing the Address Line 1 and dropping it into the check, then going back and grabbing the Address Line 2 and dropping it into the check. The problem is when that Vendor name doesn't exist in the "Vendor Info" page...I want it to just paste two blank cells into the check (because I obviously don't have the address info for that Vendor)...but instead it gives me an error:
Run-Time error '91':
Object variable or With block variable not set
Sub Checks()
'
' Checks Macro
' Macro recorded 2/14/2007 by Derek Minner
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Selection.Copy
Sheets("Checks").Select
Range("I4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
View 3 Replies
View Related
May 18, 2007
Continuing with my goal to learn VBA and while playing with the following code, I encountered strange behavior of debug statements. In the code below I have put my comments to identify where the "funny behavior" is encountered.
Will appreciate if you can help me understand. I also have a simple request/question at the end of the code below: ....
View 7 Replies
View Related
Jun 19, 2007
I am having a strange error occur. I am trying to debug a function in an add-in I developed, but whenever I try to hover over a value or add a watch, the whole application crashes. It runs without crashing when I don't try to debug it.
View 3 Replies
View Related
Jun 22, 2008
I recently got a new laptop. I now have excel 2007 and vista. The debug step key, F8, does not work. It toggles out of excel when pushed. If I start the procedure in the debug menu, the SHIFT - F8 will step through though. Is there a setting I am missing? It must have somehting to do with VISTA since in the debug section it says to use F8.
View 3 Replies
View Related
Feb 12, 2014
I am trying to take the template I have created and after the information is entered, if all required is not filled in, it will highlight the cells that need filled in. I get a debug error on
VB:
Cell.Interior.ColorIndex = 6
And the file does not save elsewhere. It goes into never never land. Here is my whole code:
VB:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Start As Boolean
[Code]....
View 5 Replies
View Related
Jun 7, 2009
I'm working on a sheet where I can specify sales by selection of month (Sheetname= ZoekenMaand).
Everything works fine for the months "januari" and "februari" (yes, it's in dutch ) but from "maart" it doesn't seem to work any more.
View 3 Replies
View Related
Jun 11, 2009
I don't understand the relationships that are happening and what the final value would be if for example the PT was Red. I'm confused and was curious how four lines could all equal different values(highlighted).
UpUserPaint = UCase(RegPaint.Value)
Dim icount As Integer
LenRegPaint = Len(RegPaint.Value)
For icount = 1 To LenRegPaint
ValPAint = ValPAint + Asc(Mid(UpUserPaint, icount, 1))
Next icount
If PTRed.Value Then
ColorCompare = Abs(Pallet * (ValPAint + PrdtSeed - LenRegPaint))
ColorCompare = Abs( Round(ColorCompare / PrdtSeed - 7227, 0))
ColorCompare = ColorCompare And 6215971
ColorCompare = ColorCompare Xor 6215971.............................
View 4 Replies
View Related
Feb 3, 2007
I'm trying to create a macro that will send out emails to people based on an excel file that has 4 columns, nickname, purchased, owed, email address. I am able now to open the email, fill out to field, subject, body (mostly) and have it send if i change the code. The problem is kinda 2 part. I am trying to read in the amount owed cell (which is formatted to be $#.##) and then display that in the email, as well as reading in any other things and storing them to declared values. I am able to step through the code, but once it gets to the first part of reading in the nickname, it goes to the next line, you step through that, and then it immediately kicks out to the cleanup section. Below is the code... (Also, why is it that I need to set the row int to 1 insted of 2 (2 being where my data starts on the excel chart)).
Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim row, purch, owed As Integer
Dim nick As String
row = 1
purch = 0
owed = 0
View 9 Replies
View Related
Jun 26, 2007
I have a macro that calls functions from another workbook.
For example:
Private Sub Worksheet_Change(ByVal target As Range)
If ThisWorkbook.OpenCommon <> -1 Then _
Application.Run Workbooks("common.xls").name & "!Arkusz1.CellChange", target
End Sub
But when I get an error in CellChange function from "common.xls" workbook, debugger points only to the third line of the code above, not to the bad line in called function.
Is there any way to change this behaviour (maybe some tool etc.)?
View 5 Replies
View Related
Jun 15, 2008
When stepping through my macro it moves through each line of the code showing me the code as it steps through. Is there a way to step through and see the results of the code as it is going through. I have an "IF THEN" statement in the macro that is not giving me any results so I think I must have an incorrect reference in the code, but I can't see it. I think if I could watch what it is supposed to be doing as I step through I might be able to find the error.
View 4 Replies
View Related
Feb 24, 2009
I have a workbook that contains 9 worksheets. Four of the worksheets have the same row lables in column B and must always be the same. Three of the worksheets are fed from the 4th sheet so that the integrity of the lables is maintained.
The user can change the lable value to meet their needs and they can insert or delete rows (within limits) as they see fit.
The attached macro "Sub Delete_Row_All_Sheets()" works fine when I run it from Debug (F8).
However, when I run it from Forms.ComboBox the macro returns to the "y = Application.InputBox("Enter The Row Number You Wish To Delete", _" screen. If I select cancel, the results I anticipated occur but I don't want the user to have to assume this will happen.
Why does the macro return to this screen when executed from the ComboBox but not when executed from Debug?
View 14 Replies
View Related
Sep 25, 2009
I created a long macro as follows with 2 Select Case structures and the macro works fine.
View 14 Replies
View Related
Nov 20, 2009
I'm trying to create vehicle maintenance inspection program for a mechanic at work. The trouble is the he's not fond of computer and I'm trying to make it as simple as possible. There's a debug in the line
View 2 Replies
View Related
Mar 19, 2012
I have below code which I was thinking is very simple to select variable worksheets. However I get Debug error when running:
Code:
Dim rng As Range
Dim cl
Set rng = Sheets("Budgetted sku's").Range("A2:A24")
For Each cl In rng
Sheets(cl.Value).Select
Next cl
View 5 Replies
View Related
Mar 13, 2013
I put together about 10 separate macros that will log you into a site using the values in a given cell. I was having trouble with the last one because of AutoComplete remembering the username. So I put in an IF statement, and when I used F8 to go line for line, it works perfectly. However, when I click F5 and just let it play through, it doesn't log in. I tried adding a 5 second delay, but that didn't seem to work. I still get a run-time error when I hit play.
It get hung on this line:
Code:
If doc.getElementById("user_name").Value = cUsername Then
But the complete code is this:
Code:
Sub StreetLinks_Login()
'On Error Resume Next
Dim cURL As String
cURL = Worksheets("Sheet1").Range("B9").Value
[Code] ..........
View 7 Replies
View Related
Apr 7, 2008
I am trying to open a xls file and convert into csv. My macro works when I'm in debug mode. but If i run the macro (Not in debug) mode then After opening a file control is not going to next function. What is problem? Even I am not getting any error too
sub open file (FileName as string)
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim RowNo As Integer
Set xlx = CreateObject("Excel.Application")
xlx.Visible = True
'Set xlw = xlx.Workbooks.Open(SourceFolder + "" + FileName)
Workbooks.Open FileName:=SourceFolder + "" + FileName
' Columns("F:G").Select
' Selection.Delete Shift:=xlToLeft
Save_in_WDrive (FileName)
Set xlx = Nothing
end sub
View 9 Replies
View Related
Apr 3, 2007
i try to lock cells in the area the VBA code affects. My goal is to actually have affected cells by this VBA code lock immediately after anything is entered in the affected cells. Area needing Debugging is in the If - Else portion. My worksheet will be protected.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LLoop As Integer
Dim LTargetRange1 As String
Dim LDestRange1 As String
LLoop = 10
While LLoop <= 1000
'Link column B to A
LTargetRange1 = "B" & CStr(LLoop)
LDestRange1 = "A" & CStr(LLoop)
If Not Intersect(Range(LTargetRange1), Target) Is Nothing Then
If Len(Range(LTargetRange1).Value) > 0 Then
Range(LDestRange1).Value = Date
Else
Range(LDestRange1).Value = Null
End If
End If
LLoop = LLoop + 1
Wend
End Sub
View 7 Replies
View Related
Jan 4, 2008
i want to do is throw a break in my vba code if the user selects yes through a msgbox vbYesNo prompt and proceed in debug mode. is it possible to code in a break point in this fashion? my desired pseudo
if user selects yes:
set break point (to send to debug mode at that point... i dont mean to end the code with a END statement.)
if user selects no:
proceed program normally
View 6 Replies
View Related
May 1, 2009
I have code that selects and copies data from one sheet onto another sheet. the sheet that is getting data copied too has borders defined. When i run the code i get a debug error. Here is the issue.... when i remove all the borders it works fine. I have tried everything i can think of to solve the problem but have had no luck. anybody have an idea what is causing this. i attached the workbook file so you can see what is going on.
View 2 Replies
View Related
Jun 19, 2009
i m working on an excel 2007 workbook with ms project functionality. in order to be able to use ms project from within excel i m using early binding. for those who dont know what early binding is: http://www.dicks-clicks.com/excel/olBinding.htm
this works fine if the user has ms project installed on his/her pc.
if the user does not have ms project installed i remove the broken references. this works fine.
but my problem is that when i remove the reference to ms project, my vba project will not compile correctly. thus each time when a user opens the workbook the user gets a "compile error in hidden module" , since the functions of ms project are not available.
for example i get a compile error in the following source
Public Function getResID(ResName As String, ActiveProject As Project) As Integer
Dim res As Resource
For Each res In ActiveProject.Resources
If res.name = ResName Then
getResID = res.ID
Exit Function
End If
getResID = -1
Next
End Function
i just want to know what i can do to prevent the compile error? would the use of late binding remove the problem? actually i dont want to use late binding since my source code is already very complex and it would be a huge effort to change it.
View 9 Replies
View Related
Oct 29, 2009
We have had a macro running for a few years (Excel 2007 now, but started in 2003) that imports about 35 text files into separate sheets, creates a calculated SUM field for each sheet and copies that value to a title (or summary) sheet. We use this 2 to 4 times per year at inventory time, copying to a new file and deleting the old data before running the macro. The imported files initially create new workbooks, but the data is copied to the initial workbook into a distinct sheets for each file.
Recently (well, last August) this macro started hanging after importing (Workbooks.OpenText) a number of files, and not necessarily the same file every time (on repeated runs.) While trying to figure out the problem, I have now managed to get it to hang every time on the first file! However, if I am stepping through in the debugger it continues past the OpenText command and on F5:Run/Continue will then continue processing the rest of the files normally. If I delete the first file before running the macro, it then hangs on the second file instead.
Without debugging, the first file will import, display on-screen, and there it stops. If I put a break-point on the very next instruction after the import, that break-point is never reached. THINGS I'VE TRIED:.......
View 2 Replies
View Related
Aug 9, 2006
I am having a problem with a custom funciton I am trying to create. It will exit after it is finished with the IF Then Else statement. I need it to continue onto the Do loop at the bottom that does all the work.
Function UPCECheck( num As String) As Long
Dim CheckNum As Long
Dim TempCheck As Long
Dim X As Long
Dim Holdtxt As Variant
UPCECheck = 0
CheckNum = 0
Debug.Print Len(num)
If Len(num) = 12 Then
Holdtxt = num
ElseIf Len(num) < 12 Then
Holdtxt = "000000000000" & num
Holdtxt = Val(Mid(Holdtxt, Len(holdtext) - 12, 12))
End If...................
View 6 Replies
View Related
Dec 14, 2011
I have a Change Event macro that works properly. I also have several cells that contain a drop down list. If a user tries to enter an incorrect entry...the debug is triggered on my even change macro.
Here's the piece of the Change macro that has issues. Specifically, the .undo line highlights.
With Application
.ScreenUpdating = False
.EnableEvents = False
Set SelectedCell = ActiveCell
myTitle = Cells(Range("Titles").Row, Target.Column).Value
myRow = Target.Row
.Undo: myBefore = Target.Value
.Undo: myAfter = Target.Value
SelectedCell.Select
View 3 Replies
View Related