OpenText Function In Macro Hangs Unless Stepping Through Code In Debug

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


ADVERTISEMENT

Debug Code & See Results As Stepping Through

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

Jumps To Another Function While Stepping Through Code

Jul 12, 2006

Whilst stepping through code in any new sub/ function that I create in VBA, VBA Editor (seemingly arbitrarily) jumps to a line in a completely different function.

View 4 Replies View Related

Discrepancies Between Running Macro And Stepping Through The Code?

May 22, 2013

I have just written a macro to validate/clean up some data which I get on a monthly basis. Some of the columns come from a pdf file and thus excel recognises these as strings. I have written some code that would convert this string to an integer which runs fine when I step through the code. However when I run the macro from a button the number value goes from e.g. 5000 to 0.

The code is below:

VB:
Sub Condition2()
For k = 8 To LastRow
Worksheets("Bordx Format").Cells(k, i - 1).Value = CDec(Cells(k, i - 1).Value)
Next k
End Sub

View 2 Replies View Related

Macro Code Hangs/Freezes Adding Rows

Sep 15, 2006

I've managed to use some code I found to add a new row below the selected row, and duplicate all the forumlas of the source row. It worked fine dozens of times yesterday, but today it's decided not to work. It gets as far as creating the new row(s), but then just hangs & excel crashes before duplicating the formulas. I've even tried reverting to an earlier version, which also worked fine, but this crashes also!

Sub Add_New_Row()
' Unlock Worksheet
Worksheets("Sheet1").Unprotect Password:="*****"
Dim x As Long
ActiveCell.EntireRow.Select 'So you do not have to preselect entire row
If vRows = 0 Then
vRows = Application.InputBox(prompt:= _
"How many rows do you want to add?", Title:="Add Rows", _
Default:=1, Type:=1) 'Default for 1 row, type 1 is number
If vRows = False Then Exit Sub
End If
'if you just want to add cells and not entire rows
'then delete ".EntireRow" in the following line
Dim sht As Worksheet, shts() As String, i As Integer
Redim shts(1 To Worksheets.Application. ActiveWorkbook. _
Windows(1).SelectedSheets.Count)..................................

View 7 Replies View Related

Step Through & Debug VBA Macro Code

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

Function Macro Debug: Continue Onto The Do Loop At The Bottom That Does All The Work

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

Stepping Thru Code Very Slow

Mar 8, 2007

I do those things, I set every object = nothing... I even moved them up to right after I use the object. When I open the workbook, my process's shows excel at 38000K. my first go of running code, stepping thru is great... I watch my process and see that I get up to 78000K... I then exit my code, properly... and the process goes only down to about 50000K. If I run it a 2nd time excel process show almost a 100000k and stepping thru is slow, slow motion... a 3rd time and I am at 120000k. I am setting everything to nothing and can't figure it out... I have done bigger projects with more forms, recordsets, collections and never have had this problem.

View 2 Replies View Related

Microsoft Word Hangs With Excel Launch Code

Apr 29, 2012

Consider this procedure to execute a MS Word mailmerge from within Excel:

Code:
Option Explicit
Dim objword As Object
Dim odoc As Object
Dim odoc2 As Object
Dim wdsendtonewdocument As Object
Dim mypath As String

Sub merge()

[Code] ........

The application hangs on the line in red. The file name (worksheets("Frontpage").Range("B15")) exists. It hangs with periodic dialogues "Microsoft Office is waiting for another application to complete an OLE action."

I end up having to go into task manager to close the word application before I can regain Excel control again.

View 9 Replies View Related

Macro Works Stepping Through But Not When Run On Its Own?

Jul 21, 2014

I have a very simple macro that copies data from one worksheet to the other. This macro worked fine in Excel 2007. I have since migrated to to 2013. The newly arisen problem is that when I run the macro, the data is not copied to the 'Previous Part Data' worksheet. However, if I step through the code line by line, it works fine.

Here is the code:

VB:
Sheets("Current Part Data").Select 'Select the 'Current Part Data' worksheet
'Copy the data to the 'Previous Part Data' worksheet then clear the data
Range("A4:V" & CurrentPartDataFinalRow).Copy

[Code]....

I have two questions:
1. Why did this work in 2007 and not in 2013?

2. Is there something I can do to get rid of the sheet selection statements to avoid cluttering my code?

View 3 Replies View Related

Find Function Debug

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

Macro Stops Running The Macro Completely And Hangs In The Middle

Jul 3, 2007

Here in our department we made a pretty elaborate macro that takes a report and sorts them out to 17 different sheets in a one workbook. This Macro pulls a file from a specific location on our server and then opens the CSV sorts it out color codes all the important information and saves it back onto the server under you specific initials.

They are four PC's along with our Managers laptop that run this Macro daily.

About 3 weeks ago my Managers laptop stops running the Macro completely and hangs in the middle of the whole thing. Eventually crashing Excel.

We try to remove the modules and re-import them back into the personal macro workbork but this does not work. The Macro's did not change and still fully function on the other four desktops to this day.

I uninstall Office on my Managers laptop and reinstall. Import the Modules again and still hangs up in very same spot it did 3 weeks ago.

I've tried to lower the macro security to the lowest level also and I've still had no luck with this laptop. I don't understand. The Macro's function perfectly on other PC's but will not function on this laptop.

View 9 Replies View Related

Macro Hangs After Execution

Jul 11, 2006

I have written a macro .When i execute the macro the result is displayed but my excel file hangs after that.

View 3 Replies View Related

Debug Function Called From Another File

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

Code Works In Debug Mode But Will Not Run Through When Played

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

Linked Cell Combo Box Hangs Running Macro

Dec 1, 2006

I am trying to create a menu that calls macros based on your choice using a drop down combobox (from the control toolbox). Everything works except: When i try to reset the drop down to "Main Menu" using the Linked cell $B$1 excel hangs and suts down evertime. What i would like it to do is reset the drop down to "Main Menu" each time one of the other drop downs are selected. I have really enjoyed this forum and it has been a great resource for me in the past I hope someone can help. I have attaching the file for review.

View 3 Replies View Related

Macro Runs Fine In Debug But Not From ComboBox

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

Macro Works In Debug Mode But Not In Runtime

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

OpenText Into Existing Worksheet?

Sep 26, 2006

I would like to Import a Text file into a current Workbook with the worksheet name GLFBCALO. The macro below creates a new workbook instead of imported the data to existing sheet, GLFBCALO. Is there a way to use the OpenText method to import data into an existing worksheet?:

Public Sub ImportOKdata()
Dim MyFile As String
Dim ColumnsDesired

[Code]......

View 3 Replies View Related

Worksheet.Opentext Failure?

Jan 7, 2009

I am struggling with the Worksheet.Opentext code required to open a text file in excel - specifically with the date format.

For example, I have a text file containing Feb08.

When opened manually using space as deliminator it correctly returns 01/02/2008.

However, when I record the same opening action as a macro and then run same macro it returns 08/02/2009, which is incorrect. Try it and see for yourself!

View 7 Replies View Related

Opening Unicode CSV File Using Opentext

Jul 7, 2012

I have written code to export data from excel as a unicode .csv file - see [URL] .....

However I now want to open that file by vba, yet it does not format the data correctly. I have a field in the delimited data that is string (in my .csv file strings are surrounded by " to indicate strings). This string can contain a vbLf as part of the string ie. the string goes over a couple of lines in one cell.

Using vba I open the .csv file as follows:

Code:
Workbooks.OpenText filename:=singlefname, origin:=65001, DataType:=xlDelimited, textqualifier:=xlTextQualifierDoubleQuote, comma:=True

yet when the code opens the file the vbLf starts a new worksheet row messing up the layout of the .csv file. It should just indicate a new line in a cell.

How to open the file so the vbLf only creates new line in the cell does not start a new worksheet row?

View 8 Replies View Related

Code "debug" Error 13

May 29, 2009

The two code extracts below are associated with two separate worksheets in the same workbook. They work fine. They simply are used to assign either a PO# or a Temp Unit #, located in a third sheet, in their respective sheets.

The problem is that when I'm in either the Master or the Work Orders sheets where these two codes are used, and I do something simple like drag down some values or paste something in a cell, I get the "Run time error "13" type mismatch error" in the popup debug window for my VBA code. And in each case, it highlights the codeline I've color coded below:

View 2 Replies View Related

Worksheet Function In VBA Macro Code

Apr 24, 2009

I am trying to write a function in excel to use the worksheet function "small" In the vba immediate window it doesn't return anything and in the spreadshhet I get a # NAME? error when called in a cell the code is below.

Sub UseFunction()
Dim myRange As Range
Dim answer As Integer

Set myRange = Worksheets("Sheet1").Range("A1:F6")
answer = Application.WorksheetFunction.Small((myRange), 1)
MsgBox answer
End Sub

View 3 Replies View Related

VLOOKUP Function In Macro Code

Mar 18, 2008

Is it possible to Call the inbuilt Excel Functions (like VLOOKUP) in Macros. we have to pouplate cells with formula which uses VLOOKUP. one way was to update each cell with required Formula like: [code] Range("A1").value = " = 6*F7*(1-Vlookup(lookupvalue........))"[code] but this was stupid as no of cell to be populated was large and variable and moreover it will return formulae to cells rather than fixed value. What we tried was to defile an table_array as Array(x y) and then use this array to return required VLOOKUP value. However I was thinking is there any way to call function like VLOOKUP in Macros so that we can return a value to cell rather than formula.

View 3 Replies View Related

Concatenate Function To Cell Macro Code

Mar 8, 2008

Need to take column J20:J255 and column K20:K255 and concatenate into activesheet K20:K255. This needs to happen when OptionButton1.Value=True. The information in each cell will be different. The following code works well, but it will not allow me to put a space in between the two strings.

Private Sub OptionButton2_Click()
Dim DescriptionCell As Range
Set DescriptionCell = ActiveSheet.Range("D20:D54")
If OptionButton2.Value = True Then
With DescriptionCell
.NumberFormat = General
.Formula = "=CONCATENATE('Bill of Materials-3'!F20,'Bill of Materials-3'!I20)"
End With
End If
End Sub

View 2 Replies View Related

Add Nest Formula/Function To Cell With Variables Via Macro Code

May 22, 2008

I would like to use a varible Cell for the following forumula:

ActiveCell.Formula = "= ROUND(PIExpDat(""TimeEq('""&Cells(RowNdxG,4)&F$2,F$3,F$4,F$5,0,)/3600,1)"

I have underlined the variable. This is not working but is rather showing up as a string value Cells(RowNdxG, 4).

View 6 Replies View Related

Macro Code To Add Sum Formula/Function, With Variable Rows, To Cell

May 29, 2008

I am having to copy and paste rows of data into a new worksheet where the rows sizes change and I am wanting to add a new row at the end of the pasted rows but with the sumation formula to add the relevant column

e.g copy range B14:AA17 with in this case columns E to AA holding the numerical values. Therefore I wish in cell E18 to sum the value of E14:E17 and so on ending with cell AA18 holding the sum of AA14:AA17

As these vary I have all relevant variables, Range to add sumation values to eg E18:AA18
Start Cell E14 and so on.

I tried adding "=SUM(x:d)" where x and d are vars relating the the column cell required eg x = E14 and d = E17

View 3 Replies View Related

Stepping Thru Columns Beyond Col Z ( Into AA Etc)

Jun 22, 2006

I have some code which steps through a range of columns from A to Z ( using Chr(asc(col))+1 as the stepper.

This works fine until it encounters col AA then fails - I have added the function that does this - can you help me get beyond col Z?


Function findcol(strTitle As String, ws As Worksheet)
If Left(strTitle, 1) = "0" Then
strTitle = Right(strTitle, Len(strTitle) - 1)
End If
col = "A"
findcol = ""
While ws.Range(col & "1").Value <> "" And findcol = ""
If ws.Range(col & "1").Value = strTitle Then
findcol = col
End If

col = Chr(Asc(col) + 1)
Wend
End Function

View 8 Replies View Related

For/next Hangs Up On Second Time Around

Jan 25, 2007

I have and issue within my For/Next loop. I'm simply gathering name and address data from columns in the workbook and printing them out (one at a time) onto a preprinted form letter. I use offsetts to move around the data row and get the appropriate items(address1, address2, city, etc). The first time through, it prints out. I'm then raising the row offset by 1 to get the second name and address data.
I'm using a static starting point on the data sheet but the second time through, I get a Runtime error 1004 at the point where it is supposed to select that starting point. Oddly, entering Debug I have done something which allows it to continue. It gets the second batch of data and prints properly. I have not been able to duplicate how that happened.

View 6 Replies View Related

Excel 2007 :: Copy Fill Without Stepping Value?

Dec 30, 2012

I have excel 2007. I have a workbook with 2 tabs set up as follows:

Tab ATab B

Tab A contains a column with the source data, which will be constantly overwritten

Tab B has a row which references the data in tab A

I would like to copy the reference formula in Tab B down for say 100 rows, but when I use the fill tool, it automatically moves the reference cell up one. I want it to remain the same as the original.

E.g
Tab B, Row 1
ColA = Tab A, Row 1
ColB = Tab A, Row 2
ColC = Tab A, Row 3

When I fill copy the above; on Tab B, Row 2, the formula changes to ColA = Tab A, Row 2, ColB = Tab A, Row 3 etc. I would like them to remain as ColA = Row 1, ColB = Row 2 etc.

I will then use Tab A to input each rows data in Tab B, having converted the previous row into just text so it doesn't change with each update.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved