VBA Code Stops - When WB Is Opened By Another WB

Nov 4, 2009

I have 3 Work books - one (WB1) checks its version number against an online record and if they dont match it opens WB2 which then proceeds to download the updated version copy information from WB1 to its self which it then pastes into WB3

WB1 then gets deleted and WB3 Renamed to the old name of WB1

the issue i have is when i open WB2 using the button that also checks for updates on WB1.

WB2's code seems to just stop when it gets to the point of updating WB3 no error messages or nothing it just stops!

NewMasters(2).xls = WB1
Updater.xls = WB2
NewVersion.xls = WB3

View 14 Replies


ADVERTISEMENT

VBA Code Stops

Dec 14, 2007

My code below works great all the way to the end. When the last message box comes up, If the user chooses Yes. I want them to be directed to the sheet "C123". But currently it just stays on the sheet that I named "Home".

What am I missing here?

Private Sub CommandButton1_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Log")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Reason Code
If Trim(Me.ComboBox2.Value) = "" Then
Me.ComboBox2.SetFocus
MsgBox "Please enter a reason code and ensure that date is correct!"
Exit Sub
End If

View 9 Replies View Related

Code Stops During The Loop

Apr 9, 2009

I am using Excel 2003 work PC, and when i run this simple code it stops during the loop, I have had this problem a bit its like something is hitting the esc key or ctrl - break. But no keys are being hit or are sticking.

I have closed Excel and created new work book pasted the code in but it still stops at r = r - 1, haven't done a restart yet.

Sub Macro2()
Dim r As Integer
r = 10
Do Until r = 0
ActiveCell.Value = ("Shut down in " & r)
Application.Wait Now + TimeValue("0:00:01")
r = r - 1
Loop
Application.Quit
End Sub

View 9 Replies View Related

Code Stops Working After X Rows

Nov 23, 2008

I'm using Excel 2007 and my s/s is 360000 rows deep.
To cut+paste formulas+formats from one column to another I'm using the following
Sub move_formula_and_formats_from_I_to_L()

Dim cell As Range

Application.ScreenUpdating = False

For Each cell In Range("I1", Cells(Rows.Count, "I").End(xlUp))
With cell
If .HasFormula And Not .Offset(1).HasFormula Then
.Cut Destination:=.Offset(1, 3)
End If
End With
Next cell

Application.ScreenUpdating = True

End Sub
The code stops working after 159000 rows and highlights (in yellow) the line:
.Cut Destination:=.Offset(1, 3)

View 9 Replies View Related

Code Stops When UserForm Shown

Nov 17, 2006

I have an Access program that acts as a dashboard to open Excel reports. One of the Excel workbooks opens a form in the Auto_Open routine. My problem is that control is never passed back to access after the form opens. It appears that the code stops executing until the userform is closed. How can I open the excel workbook, show the Excel userform, and continue processing my Access code?

Set XL = Excel.Application
With XL
.Workbooks.Open FileName:=FileName, ReadOnly:=True
. ActiveWorkbook.RunAutoMacros xlAutoOpen
End With
XL.Visible = True


' Excel Code
Sub Auto_Open()
Unload UserForm1
UserForm1.Show
' The code get "stuck" right here
End Sub

View 4 Replies View Related

Code Stops When UserForm Shows

Dec 8, 2006

I am attempting to show a User Form during the forms Initialize code. I Load the form after extracting data from a SQL Server database. The code that Loads the form is returned to after the form closes. The problem is that when I run through the Initialize code where criteria decides whether the form is actually shown to the user. If the criteria is not met there are no issue, but if the criteria is met, then the form is opened and the rest of the Initialize code is not stepped through. As there are many If Then and a Select Case and a couple With...'s I need the rest of the Initialized code to be stepped through so after the form is closed by the user and the original code which Loaded the form is returned to I do not get an error.

Oh and the big problem is that I am not getting an error message during this, the Load code is actually repeated because when the original code is actually returned to is returned on the Load UserForm code.

Private Sub UserForm_Initialize()
Dim i As Integer, Endofdata As Integer, wsheet3 As Worksheet, wbBook As Workbook
Dim wsSheet As Worksheet, c As Variant, gTotal As Long, Score As String, g3000 As Long
Dim gTotalAdd As Integer

On Error Goto ErrorHandler:
Application. ScreenUpdating = False
'cmbIDCountry.ColumnCount = 2
Set wbBook = ThisWorkbook
Set wsheet3 = wbBook.Worksheets("UpdateDetails")
Set wsSheet = wbBook.Worksheets("Data") ....................

View 2 Replies View Related

Input Box Stops Rest Of Code Running

Jul 18, 2014

I usually just use macros to clean up Data from non-excel sources. So I wrote a macro to do this, but the process requires a date to be added, so attempted to do this via an input box. The input box works, but the code doesn't, clicking the button to which the macro is bound spits out an error 91 (object out of bounds?) when it hits the search function right after the inputbox code. Both bits work as intended separately, so I guess it's just some moronic formatting error on my behalf.

[Code] ......

View 6 Replies View Related

Workbooks.Close Function Stops Code

Feb 16, 2009

We're using XP Pro using Excel 07

The background is there are about 40 people who use a Excel based program that contains a pivot and a bunch of other tools that they use on a regular basis, this set of tools has a version number. In this excel workbook, it has a function that looks on the network drive that we have and checks the local version vs the version on our network drive, if its wrong, then the user gets a popup stating your tools are out of date, would you like to update, then they click yes and I have these lines of code

Public Function GetNewTools()
Dim MyFullName As String

'Turn off alerts
Application.DisplayAlerts = False

'Open the new version of tools
Workbooks.Open Filename:= _
"Network DriveUpdate.xlsm"

End Function

The update file has this code that executes on fileopen in the thisworkbook section by calling the following sub

The main issue we're running into is near the very end, the code never makes it to "TEST 2". After the first workbooks close, the code just stops running. No crashes, errors, freezes, anything. It just stops running and never makes it to the second msg box.

View 9 Replies View Related

Macro Stops At 1st Line Of Userform Code

May 10, 2006

I have built a small userform with 3 fields. The macro ran OK first few times. Now, when user enters data in the form and clicks OK nothing happens. I found that repeated clicking on OK or Cancel button on form had no effect. I then observed that VBA editor was open and the yellow cursor was displayed on the first code line under cmdOK_click procedure. The code line was also highlighted in yellow. There are no errors to debug and no break points etc. When I clicked the Run (or Continue) icon from the VBA toolbar, the macro completed OK. Question: Why is the macro pausing on the first line and how can I make it run without pausing for no apparent reason.

View 4 Replies View Related

Code Protection Stops Re-Naming Codename

Jan 4, 2007

I have a Userform that allows a user to select a year eg (2007) from a listbox called yearbox where Yearbox.Value = AddYear. When the user Presses 'OK' the following code runs: ...

View 9 Replies View Related

Textbox Click Stops Event Code Running

Aug 26, 2007

I have a textbox from the drawing toolbar. When someone changes a cell then clicks in the textbox, Worksheet_Change does not run. If they double click in the cell, that's OK I can capture that event and protect the sheet, stopping them clicking in it. But if they just start typing in the cell, I can't capture that. I have seen some API code which captures keypresses, but it is not practical to use as it loops repeatedly. I could lock the textbox and have the user do something to unlock it, but this is a last resort.

View 7 Replies View Related

How To Automatically Run VBA Code When Workbook Is Opened

Aug 10, 2010

How do I automatically run VBA code when a workbook is opened?

View 7 Replies View Related

Code To Warn When Vba Editor Is Opened

Jul 3, 2007

Is it possible to check, with VBA code running some sort of "If" function in the background in an open workbook within which the VBA code is placed, whether a user is opening (or attempting to open) the VBA Editor? This should see any attempt being made, whether the user uses Tools>Macro>Visual Basic Editor, Alt + F11 or right clicking on the Excel icon top left to "View Code".

View 2 Replies View Related

Code Running When Already Open But Not When Newly Opened

Feb 26, 2014

Two workbook, A & B. Code in B copies some data over to a sheet in workbook A.

It does this not problems if A has remained open, but if it has just been opened, I get a "subscript out of range" error at the "With Workbooks" line.

The bit in red is what I have recently added to allow workbook A to be closed unless needed. Since adding this, the debug error has emerged, even though there was no problem when workbook A remained permanently open.

View 3 Replies View Related

VB Code To Close Workbook Opened After Certain Date

Jan 17, 2013

I have a workbook which should only be used between certain dates

In this example between 3rd March 2013 and the 1st March 2014

Would it be possible that if the user opens the workbook outside of this date range an error message could appear then the workbook would then close ?

View 6 Replies View Related

Code To Run When Workbook Is Opened And Copy Values From Other Workbooks In It?

Feb 19, 2014

I want the code to run when we open excel workbook "TEST" and it should open up all the workbooks one by one in the folder J:ABC and copy cells C2 and C4 values in the A and B columns of TEST workbook.

e.g There are 5 workbooks in the folder J:ABC so when the TEST workbook is opened then the code should run and open 1st workbook and copy values in cells C2 and C4 to it and close the workbook.

The code should run as below:

1st workbook:

C2 value will go in Test workbook B1
C4 value will go in Test workbook A1

Close 1st workbook

2nd workbook:

C2 value will go in Test workbook B2
C4 value will go in Test workbook A2

close 2nd workbook.

3rd workbook:

C2 value will go in Test workbook B3
C4 value will go in Test workbook A3

close 3rd workbook.

and so on It will be going to next rows in A and B columns.

View 2 Replies View Related

To Get The Source Code From An Allready Opened Webpage Copied Into Xl

May 8, 2006

I nedd to first log in and then specify the wanted time period ( i. e. week) before I extract the information. Is it possible to get the source code (as string) from the last focused IE-window.

The user is supposed to use output from xl to manually fill in new values on recently mentioned webpage.

View 4 Replies View Related

Macro Stops In The Last Row

Feb 25, 2009

The macro stops in the last row - it isn't able to select a cell in another sheet than "Menu" (I tested it different variations).

View 9 Replies View Related

Tab Stops On Hidden Rows

Jan 24, 2014

I have a spread sheet which has a number of protected cells so that they user can tab only on required cells to enter data. At times some of the rows are hidden however pressing "TAB" will continue to tab through on the cells within the Hidden Rows. Is it possible to only TAB through Cells which are visible?

View 1 Replies View Related

Macro Stops Before Completion?

Apr 13, 2014

i ran some tests and it was working good only doing folders with ~100 files. i tried running the macro on all the files (~70,000), but I ran into problems with the computer going into standby while I was away. I tried running a batch of 3000 files and it completed, but only got up to around ~400 out of ~3000 records. Maybe, it stops cause of code related inefficiencies?

Here's the code:
macro_forexcelforum.txt

View 1 Replies View Related

One Macro Stops Another From Working

Dec 2, 2011

I have this macro which sits in the workbook module:

Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Static OldRng As Range

On Error Resume Next
If Application.CutCopyMode = xlCopy Or Application.CutCopyMode = xlCut Then
OldRng.EntireColumn.FormatConditions(1).Delete
OldRng.EntireRow.FormatConditions(1).Delete

[Code] .......

It's used to highlight the selected/active row.

But, as soon as I run another macro, it simply stops working entirely and I'm left with a row permanently highlighted until you manually remove the conditional formatting. All formats and cell colours controlled in the other macro stop working as well. This is the other (edited for publishing) macro, which is used to send an email, and is found in a module:

Code:
Sub Send_Mail()
'this sends an email that sends a text message

Dim OutApp As Object
Dim OutMail As Object
Dim MyButton As String
Dim strTo As String

[Code] .......

I didn't write the first macro so I'm not sure where the problem is? I'm guessing there is something in the code that is stopping it from working (i.e. running conditional formats) as soon as another macro is run? Is that was is happening?

View 5 Replies View Related

Macro Stops When Using Shortcut Key?

Dec 10, 2013

I have a macro stored a module at Personel workbook and i am using personel workbook as a hidden one. when i assign a shortcut below macro it is not working but whrn i am press F5 at VBA Editor it is working.

Here is the code:

Code:
Sub Transferdata()
On Error GoTo err1:
Application.DisplayAlerts = False

[Code]....

View 7 Replies View Related

Macro Execution Stops

Mar 12, 2009

I have a problem with the following code

Dim strProcLine As String
With ActiveWorkbook.VBProject.VBComponents(ActiveChart.CodeName).CodeModule
' MsgBox ok

' adaugat procedura goala
.CreateEventProc "Calculate", "Chart"
'MsgBox ok
strProcLine = "Format_Chart"
' MsgBox ok
.InsertLines .ProcBodyLine("Chart_Calculate", 0) + 1, strProcLine
' MsgBox ok
End With
' MsgBox ok

This is part of a larger macro, wich makes 2 pivottables and for each PT a chart, and for each chart i create an even procedure (Chart_Activate) wich calls a procedure to format the chart. Tha macro is alocated to the click even on a button in the sheet where i get the information from.

If i run the macro(click the button) with Microsoft Visual Basic Editor opened all goes ok. But if i close Microsoft Visual Basic Editor and then run the macro it stops right before .CreateEventProc "Calculate", "Chart" of the first chart , and i can't understand why. No error mesages delivered, nothing.

View 9 Replies View Related

Loop Stops Prematurely

Jan 7, 2007

I have the following code that loops through a series of data creating a covariance matrix. For some reason the loop only runs through 4 iterations and then stops. I cannot for the life of me figure out what is wrong. Any thoughts? Truncated example workbook also attached....

Sub covarmatrix()
Dim Series1 As Range
Dim Series2 As Range
Dim i As Integer
i = 0
Sheets("rawdata").Select
Do
Set Series1 = Sheets("rawdata").Range(Range("B3").Offset(0, i), Range("B65536").End(xlUp).Offset(0, i))
j = 0
Do
Set Series2 = Sheets("rawdata").Range(Range("B3").Offset(0, j), Range("B65536").End(xlUp).Offset(0, j))..............................

View 8 Replies View Related

Loop Stops Early

Jan 22, 2007

verify that this syntax is correct. I just started working with Charts in VBA and it is getting very frustrating. This code should be able to run up to 140 cycles but it quits making charts at 7. Something I'm missing? If it is of any relevance sometimes it errors out at the HasTitle and Legend properties.

Dim myChtObj As ChartObject
Dim rngChtData As Range
Dim rngChtXVal As Range
Dim rng As Range
X = 0
y = 2
z = 1

Do Until y = 8

Set rngChtData = ActiveSheet.Range("A2:A352").Offset(0, z)

View 9 Replies View Related

Concatenate Stops Calculation

Mar 23, 2007

I have figures and text that I have been trying to pick up using concatenate but when I get so far the workbook won't calculate. I have numbers plus text like this -24A They start in R8 then U8 then X8 then AA8 then AD8

In AI8 is a count of these numbers between R8 and AD8 (Maximum of 5)

My initial thought was to concatenate(r8"/",u8,"/",x8,"/"aa8,"/",ad8)

Which works but if you only have one number in R8 it looks like this -

24A///. I tried embedded If statements and concatenate and got the calculate problem. A two number example of what I would like is 24A/26B.

View 3 Replies View Related

Macro Stops At End Of Designated Range?

Apr 11, 2013

Problem with the attached Range Overrun.xlsm.

Form opens with set number of rows. End User then enters figure into C3 of how many row are to be added.

VB:
Option Explicit
Dim c As Range
Dim j As Integer

[Code]....

Macro works correctly by adding the number of rows listed in C3. It SHOULD then "name " various cells in the original and new rows.

BUT the Macro goes ON to name cells in rows BELOW the ones that are added.

So on the attached worksheet the original rows were 6 - 9. Rows 10 - 12 were added, but the macro names the cells from Rows 6 - 14.

View 2 Replies View Related

Saving As Stops Macro Working

Feb 6, 2008

i have a worksheet named for example 'allocation 1' this is a master document and is opened and modified and 'saved as' under a customer name. This then stops a few important macros working properly because they refer to the original title and not the new saved title. Is there any code that will let the macro recognise any new title it is saved under?

View 10 Replies View Related

Protection Stops Macro From Running

Jun 10, 2008

I want to make the worksheet protected, however, when I protect the worksheet the macro will not run.

View 14 Replies View Related

Endless Loop? (stops Responding)

Jun 15, 2009

Having another problem with the same macro that has been giving me trouble for a week now. Now, the macro will run, but after it finishes, excel stops responding. Is this because the macro continues to run indefinitely.

View 3 Replies View Related







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